From 59df806619ca2115a00a5e6f831f0d798d0297fe Mon Sep 17 00:00:00 2001 From: wangzhizhou Date: Fri, 30 Aug 2024 17:55:08 +0800 Subject: [PATCH] add archive and distribute directly release script --- .gitignore | 6 +++ client/release.sh | 96 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 98 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d4d28da..2d65d44 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,9 @@ iOSInjectionProject/ cache/ products/* !products/appcast.xml +client/exportOptions.plist +client/DistributionSummary.plist +client/Packaging.log +client/*.app/ +client/*.app.zip +client/*.p8 \ No newline at end of file diff --git a/client/release.sh b/client/release.sh index 2f1018e..40e1b68 100755 --- a/client/release.sh +++ b/client/release.sh @@ -2,16 +2,104 @@ #-*- coding: utf-8 -*- scheme=OrzMC +team_id=2N62934Y28 configuration=Release destination="generic/platform=macOS" git_repo_dir=$(git rev-parse --show-toplevel) derived_data_path="$git_repo_dir/DerivedData" build_dir=$git_repo_dir/build +archive_path="$build_dir/$scheme.xcarchive" client_dir=$git_repo_dir/client +export_options_plist=$client_dir/exportOptions.plist +export_path=$client_dir +export_app=$export_path/$scheme.app +export_app_zip=$export_app.zip + cd $client_dir -xcodebuild archive \ - -derivedDataPath $derived_data_path \ - -archivePath "$build_dir/$scheme" \ + +# Archive +xcrun xcodebuild archive \ -scheme $scheme \ -configuration $configuration \ - -destination "$destination" # -dry-run \ No newline at end of file + -destination "$destination" \ + -derivedDataPath $derived_data_path \ + -archivePath $archive_path # -dry-run + +if [ $? -ne 0 ]; then + echo archive failed! + exit -1 +fi + +# make export options plist file +cat > $export_options_plist < + + + + teamID + ${team_id} + method + developer-id + + +EOF + +if [ $? -ne 0 ]; then + echo create export plist failed! + exit -2 +fi + +# Export +xcrun xcodebuild \ + -exportArchive \ + -archivePath $archive_path \ + -exportOptionsPlist $export_options_plist \ + -exportPath $export_path # -dry-run + +if [ $? -ne 0 ]; then + echo export failed! + exit -3 +fi + +# create zip file +ditto -c -k --sequesterRsrc --keepParent $export_app $export_app_zip +if [ $? -ne 0 ]; then + echo create zip failed! + exit -4 +fi + +# Notary +apple_id="824219521@qq.com" +app_specific_password="bbgb-nzuk-trqz-uzax" +timeout_duration="1h" +xcrun notarytool submit \ + --apple-id $apple_id \ + --password $app_specific_password \ + --team-id $team_id \ + --wait \ + --timeout $timeout_duration \ + $export_app_zip + +if [ $? -ne 0 ]; then + echo notary failed! + exit -5 +fi + +# Staple +xcrun stapler staple $export_app +if [ $? -ne 0 ]; then + echo staple ticket failed! + exit -6 +fi + +# Recreate Zip for Distribution +if [ -f $export_app_zip ]; then + rm -f $export_app_zip +fi +ditto -c -k --sequesterRsrc --keepParent $export_app $export_app_zip +if [ $? -ne 0 ]; then + echo create zip with staple ticket failed! + exit -7 +fi + +# \ No newline at end of file