From 9f2ecec1e05bb421e9dba825e34a0966b16ba09a Mon Sep 17 00:00:00 2001 From: Karin Berg Date: Sat, 11 Jan 2025 21:53:37 +0100 Subject: [PATCH] [Mobile App] Add CodeMagic yaml workflow file (#1004) --- codemagic.yaml | 484 ++++++++++++++++++++++++++++++++ recipients_app/clean_build.sh | 2 +- recipients_app/ios/Podfile.lock | 20 +- 3 files changed, 495 insertions(+), 11 deletions(-) create mode 100644 codemagic.yaml diff --git a/codemagic.yaml b/codemagic.yaml new file mode 100644 index 000000000..f6b0e2bae --- /dev/null +++ b/codemagic.yaml @@ -0,0 +1,484 @@ +definitions: + instance_mac_mini_m2: &instance_mac_mini_m2 + instance_type: mac_mini_m2 + max_build_duration: 30 + + env_versions: &env_versions + flutter: 3.22.3 + xcode: 15.4 + cocoapods: 1.16.2 + java: 17 + + scripts: + - &verify_flutter_version + name: Verify Flutter version + script: | + # Verify Flutter version + echo "Verify Flutter version..." + + REQUIRED_VERSION=$(grep flutter .tool-versions | awk '{print $2}') + echo "REQUIRED_VERSION: $REQUIRED_VERSION" + CURRENT_VERSION=$(flutter --version | grep -m 1 "^Flutter" | awk '{print $2}') + echo "CURRENT_VERSION: $CURRENT_VERSION" + + if [ "$CURRENT_VERSION" != "$REQUIRED_VERSION" ]; then + echo "Error: Flutter version $REQUIRED_VERSION is required (current: $CURRENT_VERSION)" + exit 1 + else + echo "Required version: $REQUIRED_VERSION == Current version: $CURRENT_VERSION" + echo "Flutter version is correct" + fi + working_directory: recipients_app + +workflows: + android-staging-firebase-app-distribution-workflow: + name: Android Staging (Firebase App Distribution) + <<: *instance_mac_mini_m2 + + environment: + android_signing: + - social_income_upload_keystore.jks + groups: + - slack + - app-config-stage + - firebase + #- google_play # <-- (Includes GCLOUD_SERVICE_ACCOUNT_CREDENTIALS) + <<: *env_versions + + cache: + cache_paths: + - $HOME/.gradle/caches + - $FLUTTER_ROOT/.pub-cache + + scripts: + - name: Set up key.properties + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + cat >> "$CM_BUILD_DIR/recipients_app/android/key.properties" < $GOOGLE_APPLICATION_CREDENTIALS + # Define reusable section 'verify_flutter_version' + - *verify_flutter_version + - name: Get Flutter packages + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + flutter pub get + working_directory: recipients_app + - name: Build AAB with Flutter + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + # Build the Flutter APK app + flutter build apk --release \ + --flavor stage \ + -t lib/main.dart \ + --dart-define=SURVEY_BASE_URL=$SURVEY_BASE_URL \ + --dart-define=SENTRY_URL=$SENTRY_URL + working_directory: recipients_app + + artifacts: + - recipients_app/build/**/outputs/**/*.apk + - recipients_app/build/**/outputs/**/*.aab + - recipients_app/build/**/outputs/**/mapping.txt + - flutter_drive.log + + publishing: + #google_play: + # credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS + # track: internal + # submit_as_draft: true + firebase: + firebase_service_account: $FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT + android: + app_id: 1:51495651779:android:08ef862a962bc041185576 + groups: + - internal-testers + artifact_type: "apk" + + # Notifications + email: # See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email + recipients: + - sandino@socialincome.org + notify: + success: true # To receive a notification when a build succeeds + failure: false # To not receive a notification when a build fails + slack: # See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack + channel: $SLACK_CHANNEL_NAME + notify_on_build_start: false + notify: + success: true # To receive a notification when a build succeeds + failure: true # To not receive a notification when a build fails + + android-production-workflow: + name: Android Production + <<: *instance_mac_mini_m2 + + environment: + android_signing: + - social_income_upload_keystore.jks + groups: + - slack + - app-config-prod + #- google_play # <-- (Includes GCLOUD_SERVICE_ACCOUNT_CREDENTIALS) + <<: *env_versions + + cache: + cache_paths: + - $HOME/.gradle/caches + - $FLUTTER_ROOT/.pub-cache + + scripts: + - name: Set up key.properties + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + cat >> "$CM_BUILD_DIR/recipients_app/android/key.properties" < google-services.json + - *verify_flutter_version + - name: Get Flutter packages + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + flutter pub get + working_directory: recipients_app + - name: Build AAB with Flutter + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + # Build the Flutter AAB app + flutter build appbundle --release \ + --flavor prod \ + -t lib/main.dart \ + --dart-define=SURVEY_BASE_URL=$SURVEY_BASE_URL \ + --dart-define=SENTRY_URL=$SENTRY_URL + working_directory: recipients_app + + artifacts: + - recipients_app/build/**/outputs/**/*.apk + - recipients_app/build/**/outputs/**/*.aab + - recipients_app/build/**/outputs/**/mapping.txt + - flutter_drive.log + + publishing: + #google_play: + # credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS + # track: internal + # submit_as_draft: true + + # Notifications + email: # See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email + recipients: + #- sandino@socialincome.org + - karin@karinberg.de + notify: + success: true # To receive a notification when a build succeeds + failure: false # To not receive a notification when a build fails + slack: # See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack + channel: $SLACK_CHANNEL_NAME + notify_on_build_start: false + notify: + success: true # To receive a notification when a build succeeds + failure: true # To not receive a notification when a build fails + + ios-staging-testflight-workflow: + name: iOS Staging (Test Flight) + <<: *instance_mac_mini_m2 + + integrations: + app_store_connect: Social Income Recipient App + + environment: + ios_signing: + distribution_type: app_store + bundle_identifier: org.socialincome.app.stage + groups: + - slack + - app-config-stage + vars: + APP_ID: 6464113329 # Apple ID of App "Stage Social Income" + <<: *env_versions + + cache: + cache_paths: + - $FLUTTER_ROOT/.pub-cache + - $HOME/Library/Caches/CocoaPods + + scripts: + - name: Set up code signing settings on Xcode project + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + xcode-project use-profiles \ + --archive-method=app-store \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + + # Print the export options plist + more $CM_BUILD_DIR/recipients_app/ios/export_options.plist + - *verify_flutter_version + - name: Get Flutter packages & Install pods + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + flutter pub get + find . -name "Podfile" -execdir pod install \; + working_directory: recipients_app + - name: Flutter build ipa + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + # Build the Flutter iOS app + flutter build ipa --release \ + --flavor stage \ + -t lib/main.dart \ + --dart-define=SURVEY_BASE_URL=$SURVEY_BASE_URL \ + --dart-define=SENTRY_URL=$SENTRY_URL \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + working_directory: recipients_app + + artifacts: + - recipients_app/build/ios/ipa/*.ipa + - /tmp/xcodebuild_logs/*.log + - flutter_drive.log + + publishing: + # Publish to Apple's Testflight via AppStore Connect + app_store_connect: + # Use referenced App Store Connect API key from above to authenticate binary upload + auth: integration + # Whether or not to submit the uploaded build to TestFlight beta review. + # Note: This action is performed during post-processing. + submit_to_testflight: true + + # Notifications + email: # See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email + recipients: + - sandino@socialincome.org + notify: + success: true # To receive a notification when a build succeeds + failure: false # To not receive a notification when a build fails + slack: # See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack + channel: $SLACK_CHANNEL_NAME + notify_on_build_start: false + notify: + success: true # To receive a notification when a build succeeds + failure: true # To not receive a notification when a build fails + + ios-staging-firebase-app-distribution-workflow: + name: iOS Staging (Firebase App Distribution) + <<: *instance_mac_mini_m2 + + integrations: + app_store_connect: Social Income Recipient App + + environment: + ios_signing: + distribution_type: ad_hoc + bundle_identifier: org.socialincome.app.stage + groups: + - slack + - app-config-stage + - firebase + vars: + APP_ID: 6464113329 # Apple ID of App "Stage Social Income" + <<: *env_versions + + cache: + cache_paths: + - $FLUTTER_ROOT/.pub-cache + - $HOME/Library/Caches/CocoaPods + + scripts: + # - name: Set up keychain to be used for code signing using Codemagic CLI 'keychain' command + # script: keychain initialize + # - name: Fetch signing files + # script: | + # app-store-connect fetch-signing-files "org.socialincome.app.stage" \ + # --type IOS_APP_ADHOC \ + # --create + # - name: Set up signing certificate + # script: keychain add-certificates + - name: Set up code signing settings on Xcode project + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + xcode-project use-profiles \ + --archive-method=ad-hoc \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + + # Print the export options plist + more $CM_BUILD_DIR/recipients_app/ios/export_options.plist + - *verify_flutter_version + - name: Get Flutter packages & Install pods + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + flutter pub get + find . -name "Podfile" -execdir pod install \; + working_directory: recipients_app + - name: Flutter build ipa + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + # Build the Flutter iOS app + flutter build ipa --release \ + --flavor stage \ + -t lib/main.dart \ + --dart-define=SURVEY_BASE_URL=$SURVEY_BASE_URL \ + --dart-define=SENTRY_URL=$SENTRY_URL \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + working_directory: recipients_app + + artifacts: + - recipients_app/build/ios/ipa/*.ipa + - /tmp/xcodebuild_logs/*.log + - flutter_drive.log + + publishing: + # Publish to Firebase App Distribution + firebase: + firebase_service_account: $FIREBASE_APP_DISTRIBUTION_SERVICE_ACCOUNT + ios: + app_id: 1:51495651779:ios:d4d28e75065983fb185576 + groups: + - internal-testers + + # Notifications + email: # See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email + recipients: + - sandino@socialincome.org + notify: + success: true # To receive a notification when a build succeeds + failure: false # To not receive a notification when a build fails + slack: # See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack + channel: $SLACK_CHANNEL_NAME + notify_on_build_start: false + notify: + success: true # To receive a notification when a build succeeds + failure: true # To not receive a notification when a build fails + + ios-production-workflow: + name: iOS Production + <<: *instance_mac_mini_m2 + + integrations: + app_store_connect: Social Income Recipient App + + environment: + ios_signing: + distribution_type: app_store + bundle_identifier: org.socialincome.app + groups: + - slack + - app-config-prod + vars: + APP_ID: 6444860109 # Apple ID of Prod App "Social Income" + <<: *env_versions + + cache: + cache_paths: + - $FLUTTER_ROOT/.pub-cache + - $HOME/Library/Caches/CocoaPods + + scripts: + - name: Load Prod Firebase configuration + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + cd $CM_BUILD_DIR/recipients_app/ios/GoogleServicesConfig + echo $IOS_FIREBASE_SECRET > GoogleService-Info-Prod.plist + - name: Set up code signing settings on Xcode project + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + xcode-project use-profiles \ + --archive-method=app-store \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + + # Print the export options plist + more $CM_BUILD_DIR/recipients_app/ios/export_options.plist + - *verify_flutter_version + - name: Get Flutter packages & Install pods + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + flutter pub get + find . -name "Podfile" -execdir pod install \; + working_directory: recipients_app + - name: Flutter build ipa + script: | + #!/usr/bin/env sh + set -e # exit on first failed command + + # Build the Flutter iOS app + flutter build ipa --release \ + --flavor prod \ + -t lib/main.dart \ + --dart-define=SURVEY_BASE_URL=$SURVEY_BASE_URL \ + --dart-define=SENTRY_URL=$SENTRY_URL \ + --export-options-plist=$CM_BUILD_DIR/recipients_app/ios/export_options.plist + working_directory: recipients_app + + artifacts: + - recipients_app/build/ios/ipa/*.ipa + - /tmp/xcodebuild_logs/*.log + - flutter_drive.log + + publishing: + # Publish to Apple's Testflight via AppStore Connect + app_store_connect: + # Use referenced App Store Connect API key from above to authenticate binary upload + auth: integration + # Whether or not to submit the uploaded build to TestFlight beta review. + # Note: This action is performed during post-processing. + submit_to_testflight: true + + # Notifications + email: # See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email + recipients: + - sandino@socialincome.org + notify: + success: true # To receive a notification when a build succeeds + failure: false # To not receive a notification when a build fails + slack: # See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack + channel: $SLACK_CHANNEL_NAME + notify_on_build_start: false + notify: + success: true # To receive a notification when a build succeeds + failure: true # To not receive a notification when a build fails diff --git a/recipients_app/clean_build.sh b/recipients_app/clean_build.sh index 2134d69f9..01bf85e71 100755 --- a/recipients_app/clean_build.sh +++ b/recipients_app/clean_build.sh @@ -13,7 +13,7 @@ fi # Verify Flutter version echo "Verify Flutter version..." REQUIRED_VERSION=$(grep flutter .tool-versions | awk '{print $2}') -CURRENT_VERSION=$(flutter --version | head -n 1 | awk '{print $2}') +CURRENT_VERSION=$(flutter --version | grep -m 1 "^Flutter" | awk '{print $2}') if [ "$CURRENT_VERSION" != "$REQUIRED_VERSION" ]; then echo "Error: Flutter version $REQUIRED_VERSION is required (current: $CURRENT_VERSION)" exit 1 diff --git a/recipients_app/ios/Podfile.lock b/recipients_app/ios/Podfile.lock index ba6dd0339..76837dde9 100644 --- a/recipients_app/ios/Podfile.lock +++ b/recipients_app/ios/Podfile.lock @@ -222,12 +222,12 @@ CHECKOUT OPTIONS: SPEC CHECKSUMS: AppCheckCore: 9feb4300caa596a36416cde10674dc5bec1e022e - cloud_firestore: 003d53b6b8b392600b7769acf9421cc4f23e5911 + cloud_firestore: 28753092b326c43b17251b50aa6c5b3247c939e5 Firebase: 0312a2352584f782ea56f66d91606891d4607f06 - firebase_app_check: 717089a2df93747620263dd6c8e444bde5699b7e - firebase_auth: 5719ddc9f654b813405899480e84971bd8e61235 - firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197 - firebase_messaging: 06391e8f35dc65a00c56580266285263d2861f10 + firebase_app_check: d2513b120608284733805c98e80b5b11c1bf705e + firebase_auth: f17bd6bfc0bc3d83c6df9dc3829e5b6fee10b147 + firebase_core: 3b49a055ff54114cae400581c13671fe53936c36 + firebase_messaging: 30fa3ec8cd0dc8a860b7817548911b97345a0875 FirebaseAppCheck: 148fa858b8070710c8f83d3f545b5f1e85d104a4 FirebaseAppCheckInterop: 6a1757cfd4067d8e00fccd14fcc1b8fd78cfac07 FirebaseAuth: c0f93dcc570c9da2bffb576969d793e95c344fbb @@ -245,19 +245,19 @@ SPEC CHECKSUMS: FirebaseMessaging: 88950ba9485052891ebe26f6c43a52bb62248952 FirebaseSharedSwift: 0274086954b1b2d5fd7e829eccc587044d72a4ba Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 - flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778 + flutter_native_splash: 35ddbc7228eafcb3969dcc5f1fbbe27c1145a4f0 GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6 leveldb-library: cc8b8f8e013647a295ad3f8cd2ddf49a6f19be19 nanopb: 438bc412db1928dac798aa6fd75726007be04262 - package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 + package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 RecaptchaInterop: 7d1a4a01a6b2cb1610a47ef3f85f0c411434cb21 Sentry: e9215d7b17f7902692b4f8700e061e4f853e3521 - sentry_flutter: 927eed60d66951d1b0f1db37fe94ff5cb7c80231 - url_launcher_ios: 6116280ddcfe98ab8820085d8d76ae7449447586 - webview_flutter_wkwebview: be0f0d33777f1bfd0c9fdcb594786704dbf65f36 + sentry_flutter: ba644c90ccccb202066a5218a593d1c35584cd37 + url_launcher_ios: c14c42eb16c26cfb6c43c2e40ce35a4085431791 + webview_flutter_wkwebview: 3a409e0c27995945d2dabd90079927fba5c34492 PODFILE CHECKSUM: f727177ee8bd2fa0ad40e98c3b4299dfade495ac