From 5b64c308f0ccdbfcbccd0e9f7d2b91c339e58878 Mon Sep 17 00:00:00 2001 From: richardo2016x Date: Mon, 13 May 2024 20:12:59 +0800 Subject: [PATCH] chore: code cleanup. --- .github/workflows/ios_release.yml | 1 - apps/mobile/scripts/deploy-android.sh | 20 ++++---- apps/mobile/scripts/deploy-ios-adhoc.sh | 63 +++++++++++++++++-------- 3 files changed, 54 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ios_release.yml b/.github/workflows/ios_release.yml index 64b23967a..351534a73 100644 --- a/.github/workflows/ios_release.yml +++ b/.github/workflows/ios_release.yml @@ -68,7 +68,6 @@ jobs: cd apps/mobile; yarn; yarn prepare-archive; - export SENTRY_DISABLE_AUTO_UPLOAD=true; # security unlock-keychain -p ${{ secrets.KEYCHAIN_PASS }} ~/Library/Keychains/login.keychain-db security unlock-keychain -p ${{ secrets.KEYCHAIN_PASS }} login.keychain diff --git a/apps/mobile/scripts/deploy-android.sh b/apps/mobile/scripts/deploy-android.sh index 60d9bde7c..6e732ad50 100755 --- a/apps/mobile/scripts/deploy-android.sh +++ b/apps/mobile/scripts/deploy-android.sh @@ -28,9 +28,9 @@ BUILD_DATE=`date '+%Y%m%d_%H%M%S'` version_bundle_name="$BUILD_DATE-${android_version_name}.${android_version_code}" version_bundle_suffix="" apk_name="rabby-mobile.apk" -deployment_local_dir="$script_dir/deployments" +deployment_local_dir="$script_dir/deployments/android" -rm -rf $deployment_local_dir/android && mkdir -p $deployment_local_dir/android; +rm -rf $deployment_local_dir && mkdir -p $deployment_local_dir; build_alpha() { yarn; @@ -54,7 +54,7 @@ build_appstore() { } # ============ prepare version.json :start ============== # -unix_replace_variables $script_dir/tpl/android/version.json $deployment_local_dir/android/version.json \ +unix_replace_variables $script_dir/tpl/android/version.json $deployment_local_dir/version.json \ --var-APP_VER_CODE=$android_version_code \ --var-APP_VER="$android_version_name" # ============ prepare version.json :end ============== # @@ -68,7 +68,7 @@ possible_changelogs=( for changelog in "${possible_changelogs[@]}"; do if [ -f $changelog ]; then echo "[deploy-android] found changelog: $changelog" - cp $changelog $deployment_local_dir/android/ + cp $changelog $deployment_local_dir/ break fi done @@ -81,14 +81,14 @@ if [ $buildchannel == "appstore" ]; then [ -z $android_export_target ] && android_export_target="$project_dir/android/app/build/outputs/bundle/release/app-release.aab" [[ -z $SKIP_BUILD || ! -f $android_export_target ]] && build_appstore - cp $android_export_target $deployment_local_dir/android/ + cp $android_export_target $deployment_local_dir/ else version_bundle_suffix=".apk" staging_dir_suffix="" [ -z $android_export_target ] && android_export_target="$project_dir/android/app/build/outputs/apk/release/app-release.apk" [[ -z $SKIP_BUILD || ! -f $android_export_target ]] && build_alpha - cp $android_export_target $deployment_local_dir/android/$apk_name + cp $android_export_target $deployment_local_dir/$apk_name fi # # leave here for debug @@ -128,10 +128,10 @@ echo "[deploy-android] start sync..." if [ "$REALLY_UPLOAD" == "true" ]; then echo "[deploy-android] will be backup at $backup_s3_dir (not public)" - aws s3 sync $deployment_local_dir/android $backup_s3_dir/ --exclude '*' --include "*.json" --acl authenticated-read --content-type application/json --exact-timestamps - aws s3 sync $deployment_local_dir/android $backup_s3_dir/ --exclude '*' --include "*.md" --acl authenticated-read --content-type text/plain --exact-timestamps - aws s3 sync $deployment_local_dir/android $backup_s3_dir/ --exclude '*' --include "*.apk" --acl authenticated-read --content-type application/vnd.android.package-archive --exact-timestamps - aws s3 sync $deployment_local_dir/android $backup_s3_dir/ --exclude '*' --include "*.aab" --acl authenticated-read --content-type application/x-authorware-bin --exact-timestamps + aws s3 sync $deployment_local_dir $backup_s3_dir/ --exclude '*' --include "*.json" --acl authenticated-read --content-type application/json --exact-timestamps + aws s3 sync $deployment_local_dir $backup_s3_dir/ --exclude '*' --include "*.md" --acl authenticated-read --content-type text/plain --exact-timestamps + aws s3 sync $deployment_local_dir $backup_s3_dir/ --exclude '*' --include "*.apk" --acl authenticated-read --content-type application/vnd.android.package-archive --exact-timestamps + aws s3 sync $deployment_local_dir $backup_s3_dir/ --exclude '*' --include "*.aab" --acl authenticated-read --content-type application/x-authorware-bin --exact-timestamps if [ $buildchannel == 'selfhost-reg' ]; then echo "[deploy-android] will public at $staging_s3_dir, served as $staging_cdn_baseurl" diff --git a/apps/mobile/scripts/deploy-ios-adhoc.sh b/apps/mobile/scripts/deploy-ios-adhoc.sh index da3c5c726..12ac72152 100755 --- a/apps/mobile/scripts/deploy-ios-adhoc.sh +++ b/apps/mobile/scripts/deploy-ios-adhoc.sh @@ -5,7 +5,7 @@ project_dir=$(dirname $script_dir) . $script_dir/fns.sh --source-only -[ -z $buildchannel ] && export buildchannel="selfhost-reg"; +export buildchannel="selfhost-reg"; export BUILD_TARGET_PLATFORM="ios"; check_build_params; check_s3_params; @@ -17,28 +17,52 @@ proj_version=$(node --eval="process.stdout.write(require('./package.json').versi app_display_name=$(node --eval="process.stdout.write(require('./app.json').displayName)"); cd $script_dir; -ouput_dir=$project_dir/ios/Package/latest -deployment_local_dir="$script_dir/deployments" +ouput_dir=$project_dir/ios/Package/adhoc +deployment_local_dir="$script_dir/deployments/ios-adhoc" -tmp_dir="$script_dir/deployments/tmp" -mkdir -p $tmp_dir +rm -rf $deployment_local_dir && mkdir -p $deployment_local_dir; -xcodebuild -project $project_dir/ios/RabbyMobile.xcodeproj -target "RabbyMobile" -showBuildSettings -json | plutil -convert xml1 - -o $tmp_dir/RabbyMobileAdHoc.plist +mkdir -p "$script_dir/deployments/tmp" + +xcodebuild -project $project_dir/ios/RabbyMobile.xcodeproj -target "RabbyMobile" -showBuildSettings -json | plutil -convert xml1 - -o $script_dir/deployments/tmp/RabbyMobileAdHoc.plist ios_version_name=$(/usr/libexec/PlistBuddy -c "Print:CFBundleShortVersionString" $project_dir/ios/RabbyMobile/Info.plist) -ios_version_code=$(/usr/libexec/PlistBuddy -c "Print:0:buildSettings:CURRENT_PROJECT_VERSION" $tmp_dir/RabbyMobileAdHoc.plist) +ios_version_code=$(/usr/libexec/PlistBuddy -c "Print:0:buildSettings:CURRENT_PROJECT_VERSION" $script_dir/deployments/tmp/RabbyMobileAdHoc.plist) cd $project_dir/ios; -unix_replace_variables $script_dir/tpl/ios/version.json $script_dir/deployments/ios/version.json \ +unix_replace_variables $script_dir/tpl/ios/version.json $deployment_local_dir/version.json \ --var-DOWNLOAD_URL=$cdn_deployment_urlbase/ios/ \ --var-APP_VER_CODE=$ios_version_code \ --var-APP_VER="$proj_version" -if [[ -z $SKIP_BUILD || ! -f $ouput_dir/RabbyMobile.ipa ]]; then +# ============ prepare changelogs :start ============== # +possible_changelogs=( + "$project_dir/src/changeLogs/$proj_version.md" +) + +for changelog in "${possible_changelogs[@]}"; do + if [ -f $changelog ]; then + echo "[deploy-ios-adhoc] found changelog: $changelog" + cp $changelog $deployment_local_dir/ + break + fi +done +# ============ prepare changelogs :end ============== # + +build_adhoc() { + cd $project_dir; + yarn; + yarn syncrnversion; cd $project_dir/ios; bundle install && bundle exec pod install; cd $project_dir; bundle exec fastlane ios adhoc; +} + +if [[ -z $SKIP_BUILD || ! -f $ouput_dir/RabbyMobile.ipa ]]; then + echo "[deploy-ios-adhoc] start build..." + build_adhoc; + echo "[deploy-ios-adhoc] finish build." fi file_date=$(date -r $ouput_dir/RabbyMobile.ipa '+%Y%m%d_%H%M%S') @@ -47,13 +71,13 @@ deployment_s3_dir=$S3_IOS_PUB_DEPLOYMENT/ios-$version_bundle_name deployment_cdn_baseurl=$cdn_deployment_urlbase/ios-$version_bundle_name manifest_plist_url="itms-services://?action=download-manifest&url=$deployment_cdn_baseurl/manifest.plist" -cp $ouput_dir/RabbyMobile.ipa $deployment_local_dir/ios/rabbymobile.ipa -cp $ouput_dir/manifest.plist $deployment_local_dir/ios/manifest.plist +cp $ouput_dir/RabbyMobile.ipa $deployment_local_dir/rabbymobile.ipa +cp $ouput_dir/manifest.plist $deployment_local_dir/manifest.plist -/usr/libexec/PlistBuddy -c "Set:items:0:metadata:title Rabby Wallet" $deployment_local_dir/ios/manifest.plist -/usr/libexec/PlistBuddy -c "Set:items:0:assets:0:url $deployment_cdn_baseurl/rabbymobile.ipa" $deployment_local_dir/ios/manifest.plist # appURL -/usr/libexec/PlistBuddy -c "Set:items:0:assets:1:url $deployment_cdn_baseurl/icon_57x57@57w.png" $deployment_local_dir/ios/manifest.plist # displayImageURL -/usr/libexec/PlistBuddy -c "Set:items:0:assets:2:url $deployment_cdn_baseurl/icon_512x512@512w.png" $deployment_local_dir/ios/manifest.plist # fullSizeImageURL +/usr/libexec/PlistBuddy -c "Set:items:0:metadata:title Rabby Wallet" $deployment_local_dir/manifest.plist +/usr/libexec/PlistBuddy -c "Set:items:0:assets:0:url $deployment_cdn_baseurl/rabbymobile.ipa" $deployment_local_dir/manifest.plist # appURL +/usr/libexec/PlistBuddy -c "Set:items:0:assets:1:url $deployment_cdn_baseurl/icon_57x57@57w.png" $deployment_local_dir/manifest.plist # displayImageURL +/usr/libexec/PlistBuddy -c "Set:items:0:assets:2:url $deployment_cdn_baseurl/icon_512x512@512w.png" $deployment_local_dir/manifest.plist # fullSizeImageURL echo "[deploy-ios-adhoc] will upload to $deployment_s3_dir" echo "[deploy-ios-adhoc] will be served at $deployment_cdn_baseurl" @@ -62,10 +86,11 @@ echo "" if [ "$REALLY_UPLOAD" == "true" ]; then echo "[deploy-ios-adhoc] start sync to $deployment_s3_dir..." - aws s3 sync $script_dir/deployments/ios $deployment_s3_dir/ --exclude '*' --include "*.ipa" --acl public-read --content-type application/octet-stream - aws s3 sync $script_dir/deployments/ios $deployment_s3_dir/ --exclude '*' --include "*.plist" --acl public-read --content-type application/x-plist - aws s3 sync $script_dir/deployments/ios $deployment_s3_dir/ --exclude '*' --include "*.png" --acl public-read --content-type image/png - aws s3 sync $script_dir/deployments/ios $deployment_s3_dir/ --exclude '*' --include "*.json" --acl public-read --content-type application/json + aws s3 sync $deployment_local_dir $deployment_s3_dir/ --exclude '*' --include "*.ipa" --acl public-read --content-type application/octet-stream --exact-timestamps + aws s3 sync $deployment_local_dir $deployment_s3_dir/ --exclude '*' --include "*.plist" --acl public-read --content-type application/x-plist --exact-timestamps + aws s3 sync $deployment_local_dir $deployment_s3_dir/ --exclude '*' --include "*.png" --acl public-read --content-type image/png --exact-timestamps + aws s3 sync $deployment_local_dir $deployment_s3_dir/ --exclude '*' --include "*.json" --acl public-read --content-type application/json --exact-timestamps + # aws s3 sync $deployment_local_dir $deployment_s3_dir/ --exclude '*' --include "*.md" --acl public-read --content-type text/plain --exact-timestamps node $script_dir/notify-lark.js "$manifest_plist_url" ios fi