From 5e10079b4da2ae199ae6d4418873ce875386ea92 Mon Sep 17 00:00:00 2001 From: Sk Niyaj Ali Date: Sat, 30 Nov 2024 03:02:03 +0530 Subject: [PATCH] Refactor: Migrate to fastlane for android & ios firebase app distribution (#1824) This commit migrates the Android and iOS Firebase app distribution process to use Fastlane. - Removed the custom Gradle task for Firebase app distribution. - Removed the firebase appdistribution plugin from the project. - Implemented `android deploy_on_firebase` Fastlane lane for Android Firebase app distribution. - Implemented `ios deploy_on_firebase` Fastlane lane for iOS Firebase app distribution. - Updated the internal release workflow to trigger the Fastlane lanes. - Updated documentation to reflect the changes. - Updated the weekly schedule workflow to trigger the new workflow for internal release. --- .../build_and_publish_on_platforms.yaml | 34 ++- .../workflows/internal_or_beta_release.yml | 280 ------------------ .github/workflows/weekly.yaml | 2 +- build.gradle.kts | 1 - fastlane/FastFile | 12 + fastlane/README.md | 12 +- fastlane/report.xml | 4 +- gradle/libs.versions.toml | 2 - mifospay-android/build.gradle.kts | 7 - 9 files changed, 43 insertions(+), 311 deletions(-) delete mode 100644 .github/workflows/internal_or_beta_release.yml diff --git a/.github/workflows/build_and_publish_on_platforms.yaml b/.github/workflows/build_and_publish_on_platforms.yaml index 2a4b2e554..5d219b8b9 100644 --- a/.github/workflows/build_and_publish_on_platforms.yaml +++ b/.github/workflows/build_and_publish_on_platforms.yaml @@ -82,9 +82,6 @@ jobs: run: | ./gradlew :mifospay-android:assembleRelease - - - - name: Upload Android Artifact uses: actions/upload-artifact@v4 with: @@ -96,11 +93,6 @@ jobs: ./mifospay-android/build/outputs/apk/prod/release/mifospay-android-prod-release.apk - - - - - publish_android_on_firebase: name: Deploy Android App On Firebase needs: [ build_android, generate_release_info ] @@ -118,6 +110,19 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v4 + - name: Configure Ruby + uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0 + with: + bundler-cache: true + + - name: Install Fastlane + run: | + gem install bundler:2.2.27 + bundle install --jobs 4 --retry 3 + bundle exec fastlane add_plugin firebase_app_distribution + bundle exec fastlane add_plugin increment_build_number + + - uses: ./.github/actions/inflate-secrets name: Inflate Secrets with: @@ -150,11 +155,8 @@ jobs: - name: ☁️ Deploy to Firebase env: - KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} - KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} - KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} VERSION_CODE: ${{ needs.generate_release_info.outputs.version_code }} - run: ./gradlew appDistributionUploadProdRelease --no-configuration-cache + run: bundle exec fastlane android deploy_on_firebase publish_android_on_playstore: name: Publish Android App On Play Store @@ -518,12 +520,12 @@ jobs: shell: pwsh run: | Compress-Archive -Path './all-artifacts/web-app/*' -DestinationPath './all-artifacts/mifospay-web-app.zip' - + # Rename Ubuntu desktop artifact - name: Rename Ubuntu Desktop Artifact run: | mv ./all-artifacts/desktop-app-ubuntu-latest/mifoswallet_1.0.0-1_amd64.deb ./all-artifacts/desktop-app-ubuntu-latest/MifosWallet-1.0.0.deb - + - name: Download Git Changelog uses: actions/download-artifact@v4 @@ -539,8 +541,8 @@ jobs: prerelease: true files: | ./all-artifacts/android-app/prod/release/mifospay-android-prod-release.apk - ./all-artifacts/android-app/prod/release/mifospay-android-demo-release.apk - ./all-artifacts/desktop-app-windows-latest/MifosWallet-1.0.0.exe + ./all-artifacts/android-app/demo/release/mifospay-android-demo-release.apk + ./all-artifacts/desktop-app-windows-latest/exe/MifosWallet-1.0.0.exe ./all-artifacts/desktop-app-windows-latest/msi/MifosWallet-1.0.0.msi ./all-artifacts/desktop-app-macos-latest/MifosWallet-1.0.0.dmg ./all-artifacts/desktop-app-ubuntu-latest/MifosWallet-1.0.0.deb diff --git a/.github/workflows/internal_or_beta_release.yml b/.github/workflows/internal_or_beta_release.yml deleted file mode 100644 index 5e4c22d72..000000000 --- a/.github/workflows/internal_or_beta_release.yml +++ /dev/null @@ -1,280 +0,0 @@ -name: Internal Or Beta Release - -on: - workflow_dispatch: - inputs: - release_type: - required: false - default: 'internal' - description: Please select the release type - type: choice - options: - - internal - - beta - - publish_to_play_store: - required: false - default: false - description: Publish to Play Store? - type: boolean - - publish_ios: - required: false - default: false - description: Publish to Firebase iOS App Distribution? - type: boolean - -env: - SUPPLY_UPLOAD_MAX_RETRIES: 5 - -jobs: - build_desktop_app: - strategy: - matrix: - os: - - macos-latest - - ubuntu-latest - - windows-latest - - runs-on: ${{ matrix.os }} - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-java@v4 - with: - distribution: 'zulu' - java-version: 17 - - - name: Build Desktop App - env: - NOTARIZATION_APPLE_ID: ${{ secrets.NOTARIZATION_APPLE_ID }} - NOTARIZATION_PASSWORD: ${{ secrets.NOTARIZATION_PASSWORD }} - NOTARIZATION_TEAM_ID: ${{ secrets.NOTARIZATION_TEAM_ID }} - run: ./gradlew packageReleaseDistributionForCurrentOS - - - name: Upload Windows Apps - if: matrix.os == 'windows-latest' - uses: actions/upload-artifact@v4 - with: - name: desktop-app-${{ matrix.os }} - path: | - ./mifospay-desktop/build/compose/binaries/main-release/exe/*.exe - ./mifospay-desktop/build/compose/binaries/main-release/msi/*.msi - - - name: Upload Linux App - if: matrix.os == 'ubuntu-latest' - uses: actions/upload-artifact@v4 - with: - name: desktop-app-${{ matrix.os }} - path: './mifospay-desktop/build/compose/binaries/main-release/deb/*.deb' - - - name: Upload MacOS App - if: matrix.os == 'macos-latest' - uses: actions/upload-artifact@v4 - with: - name: desktop-app-${{ matrix.os }} - path: './mifospay-desktop/build/compose/binaries/main-release/dmg/*.dmg' - - distribute_android_app: - name: Github, Firebase Release - needs: [ build_desktop_and_ios_app ] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up JDK 17 - uses: actions/setup-java@v4.2.2 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - - uses: ./.github/actions/create-release-number - name: Create Release Number - id: rel_number - - - uses: ./.github/actions/inflate-secrets - name: Inflate Secrets - with: - keystore: ${{ secrets.ORIGINAL_KEYSTORE_FILE }} - google-services: ${{ secrets.GOOGLESERVICES }} - playstore-creds: ${{ secrets.PLAYSTORECREDS }} - firebase-creds: ${{ secrets.FIREBASECREDS }} - - - uses: ./.github/actions/create-release-notes - name: Create Release Notes - with: - tag-name: ${{ steps.rel_number.outputs.version }} - gh-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Release - env: - KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} - KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} - KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} - VERSION_CODE: ${{ steps.rel_number.outputs.version-code }} - run: | - ./gradlew :mifospay-android:assembleRelease - - - name: Archive Build - uses: actions/upload-artifact@v4 - with: - path: ./**/*.apk - - - name: Create Version File - if: github.event.inputs.release_type == 'beta' - shell: bash - env: - VERSION_CODE: ${{ steps.rel_number.outputs.version-code }} - run: | - echo $VERSION_CODE > ./mifospay-android/build/outputs/version_code.txt - - - name: Download Desktop Artifacts - uses: actions/download-artifact@v4 - with: - pattern: desktop-app-* - path: desktop-apps - - - name: Create Github Pre-Release - if: github.event.inputs.release_type == 'beta' - uses: softprops/action-gh-release@v2.0.8 - with: - tag_name: ${{ steps.rel_number.outputs.version }} - body_path: ./mifospay-android/build/outputs/changelogGithub - draft: false - prerelease: true - files: | - ./mifospay-android/build/outputs/apk/demo/release/mifospay-android-demo-release.apk - ./mifospay-android/build/outputs/apk/prod/release/mifospay-android-prod-release.apk - ./mifospay-android/build/outputs/version_code.txt - desktop-apps/* - - - - name: ☁️ Deploy to Firebase - env: - KEYSTORE_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_FILE_PASSWORD }} - KEYSTORE_ALIAS: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS }} - KEYSTORE_ALIAS_PASSWORD: ${{ secrets.ORIGINAL_KEYSTORE_ALIAS_PASSWORD }} - VERSION_CODE: ${{ steps.rel_number.outputs.version-code }} - run: ./gradlew appDistributionUploadProdRelease --no-configuration-cache - - - name: Print `git status` - run: git status - - distribute_ios_app: - name: Build iOS App - if: ${{ github.event.inputs.release_type == 'beta' && github.event.inputs.publish_ios == true }} - needs: [ distribute_android_app ] - runs-on: macos-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - - name: Set up JDK 17 - uses: actions/setup-java@v4.2.2 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - - name: Configure Ruby - uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0 - with: - bundler-cache: true - - - name: Install Fastlane - run: | - gem install bundler:2.2.27 - bundle install --jobs 4 --retry 3 - bundle exec fastlane add_plugin firebase_app_distribution - bundle exec fastlane add_plugin increment_build_number - - - name: Upload iOS App to Firebase Distribution - run: bundle exec fastlane ios deploy_on_firebase - - - name: Print `git status` - run: git status - - play_publish: - name: Play Publish - if: ${{ inputs.publish_to_play_store == true }} - runs-on: macos-latest - concurrency: - group: playstore_deploy - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Set up JDK 17 - uses: actions/setup-java@v4.2.2 - with: - distribution: 'temurin' - java-version: '17' - - - name: Configure Ruby - uses: ruby/setup-ruby@a2bbe5b1b236842c1cb7dd11e8e3b51e0a616acc # v1.202.0 - with: - bundler-cache: true - - - name: Install Fastlane - run: | - gem install bundler:2.2.27 - bundle install --jobs 4 --retry 3 - bundle exec fastlane add_plugin firebase_app_distribution - bundle exec fastlane add_plugin increment_build_number - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v4 - - - uses: ./.github/actions/create-release-number - name: Create Release Number - id: rel_number - - - uses: ./.github/actions/inflate-secrets - name: Inflate Secrets - with: - keystore: ${{ secrets.UPLOAD_KEYSTORE_FILE }} - google-services: ${{ secrets.GOOGLESERVICES }} - playstore-creds: ${{ secrets.PLAYSTORECREDS }} - firebase-creds: ${{ secrets.FIREBASECREDS }} - - - uses: ./.github/actions/create-release-notes - name: Create Release Notes - with: - tag-name: ${{ steps.rel_number.outputs.version }} - gh-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Build Release - env: - KEYSTORE_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_FILE_PASSWORD }} - KEYSTORE_ALIAS: ${{ secrets.UPLOAD_KEYSTORE_ALIAS }} - KEYSTORE_ALIAS_PASSWORD: ${{ secrets.UPLOAD_KEYSTORE_ALIAS_PASSWORD }} - VERSION_CODE: ${{ steps.rel_number.outputs.version-code }} - run: | - ./gradlew :mifospay-android:bundleRelease - - - name: Archive Build - uses: actions/upload-artifact@v4 - with: - name: release-aabs - path: ./**/*.aab - - - name: Deploy to Playstore Internal - run: bundle exec fastlane deploy_internal - - - name: Promote Internal to Beta - if: github.event.inputs.release_type == 'beta' - run: bundle exec fastlane promote_to_beta diff --git a/.github/workflows/weekly.yaml b/.github/workflows/weekly.yaml index e6ff7e291..100598763 100644 --- a/.github/workflows/weekly.yaml +++ b/.github/workflows/weekly.yaml @@ -31,7 +31,7 @@ jobs: github.rest.actions.createWorkflowDispatch({ owner: context.repo.owner, repo: context.repo.repo, - workflow_id: 'internal_or_beta_release.yml', + workflow_id: 'build_and_publish_on_platforms.yml', ref: 'dev', inputs: { "release_type": "beta", diff --git a/build.gradle.kts b/build.gradle.kts index c30d5aa33..84a0026c2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,6 @@ plugins { alias(libs.plugins.kotlin.parcelize) apply false alias(libs.plugins.dependencyGuard) apply false alias(libs.plugins.firebase.crashlytics) apply false - alias(libs.plugins.firebase.appdistribution) apply false alias(libs.plugins.firebase.perf) apply false alias(libs.plugins.gms) apply false alias(libs.plugins.ksp) apply false diff --git a/fastlane/FastFile b/fastlane/FastFile index b8b6eee6f..a826267db 100644 --- a/fastlane/FastFile +++ b/fastlane/FastFile @@ -34,6 +34,18 @@ platform :android do ) end + desc "Upload Android application to Firebase App Distribution" + lane :deploy_on_firebase do + release = firebase_app_distribution( + app: "1:728434912738:android:0490c291986f0a691a1dbb", + service_credentials_file: "mifospay-android/firebaseAppDistributionServiceCredentialsFile.json", + release_notes_file: "mifospay-android/build/outputs/changelogBeta", + android_artifact_type: "APK", + android_artifact_path: "mifospay-android/build/outputs/apk/prod/release/mifospay-android-prod-release.apk", + groups: "mifos-wallet-testers" + ) + end + end diff --git a/fastlane/README.md b/fastlane/README.md index 60dee619b..8ec312936 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -39,6 +39,14 @@ Promote internal tracks to beta on Google Play Promote beta tracks to production on Google Play +### android deploy_on_firebase + +```sh +[bundle exec] fastlane android deploy_on_firebase +``` + +Upload Android application to Firebase App Distribution + ---- @@ -52,10 +60,10 @@ Promote beta tracks to production on Google Play Build iOS application -### ios distribute_ios_app +### ios deploy_on_firebase ```sh -[bundle exec] fastlane ios distribute_ios_app +[bundle exec] fastlane ios deploy_on_firebase ``` Upload iOS application to Firebase App Distribution diff --git a/fastlane/report.xml b/fastlane/report.xml index b27157959..2dfe55d87 100644 --- a/fastlane/report.xml +++ b/fastlane/report.xml @@ -5,12 +5,12 @@ - + - + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ba67c9623..35f08863e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -68,7 +68,6 @@ fineractSdk = "1.0.3" firebaseBom = "33.6.0" firebaseCrashlyticsPlugin = "3.0.2" firebasePerfPlugin = "1.4.2" -firebaseAppdistributionGradle = "5.0.0" # Kotlin KMP Dependencies kotlin = "2.0.21" @@ -354,7 +353,6 @@ mifos-spotless-plugin = { id = "mifos.spotless.plugin", version = "unspecified" firebase-crashlytics = { id = "com.google.firebase.crashlytics", version.ref = "firebaseCrashlyticsPlugin" } firebase-perf = { id = "com.google.firebase.firebase-perf", version.ref = "firebasePerfPlugin" } -firebase-appdistribution = { id = "com.google.firebase.appdistribution", version.ref = "firebaseAppdistributionGradle" } protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } roborazzi = { id = "io.github.takahirom.roborazzi", version.ref = "roborazzi" } diff --git a/mifospay-android/build.gradle.kts b/mifospay-android/build.gradle.kts index 440124dca..a511ea506 100644 --- a/mifospay-android/build.gradle.kts +++ b/mifospay-android/build.gradle.kts @@ -29,7 +29,6 @@ plugins { id("com.google.android.gms.oss-licenses-plugin") id("com.google.devtools.ksp") id("com.google.gms.google-services") - alias(libs.plugins.firebase.appdistribution) } android { @@ -86,12 +85,6 @@ android { isIncludeAndroidResources = true } } - - firebaseAppDistribution { - serviceCredentialsFile = "mifospay-android/firebaseAppDistributionServiceCredentialsFile.json" - releaseNotesFile = "mifospay-android/build/outputs/changelogBeta" - groups = "mifos-wallet-testers" - } } dependencies {