From 066629a20a4849a421c07c7ff4b74d97194e901c Mon Sep 17 00:00:00 2001 From: Daniel Markiel <39768412+DanielMarkiel@users.noreply.github.com> Date: Thu, 25 Apr 2024 10:58:16 +0200 Subject: [PATCH] feat: [ZN-549] Android adhoc builds --- .github/workflows/staging_build_android.yml | 74 +++++++++++++++++++++ fastlane/Fastfile | 26 +++++--- fastlane/README.md | 10 +-- 3 files changed, 94 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/staging_build_android.yml diff --git a/.github/workflows/staging_build_android.yml b/.github/workflows/staging_build_android.yml new file mode 100644 index 0000000..a6dc611 --- /dev/null +++ b/.github/workflows/staging_build_android.yml @@ -0,0 +1,74 @@ +name: Android Staging Build + +# Manual deployment +on: workflow_dispatch + +jobs: + build-and-publish: + runs-on: ubuntu-latest + environment: staging + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + cache: 'yarn' + node-version-file: .node-version + + - name: Setup Java + uses: actions/setup-java@v3 + with: + distribution: temurin + java-version: 17 + + - name: Make .env file + uses: SpicyPizza/create-envfile@v2.0 + with: + envkey_BASE_API_URL: ${{ vars.BASE_API_URL }} + envkey_AUTH_STORAGE_KEY: ${{ vars.AUTH_STORAGE_KEY }} + envkey_DEFAULT_LOCALE: ${{ vars.DEFAULT_LOCALE }} + envkey_MOCK_API: ${{ vars.MOCK_API }} + + # Update Google Service File + # - name: Setup Firebase File + # run: echo "${{ secrets.PROD_ANDROID_FIREBASE_FILE }}" > ./android/app/google-services.json + + # Setup Production Keystore file + # - name: Setup Keystore File + # run: echo "${{secrets.ANDROID_KEYSTORE_FILE}}" | base64 -d > "${{ github.workspace }}/production.keystore" + + # Setup Firebase Service Account file + # - name: Setup Service Account Credential Files + # run: echo "${{secrets.FIREBASE_SERVICE_ACCOUNT_JSON}}" > "${{ github.workspace }}/firebase-service-account.json" + + - name: Install + run: yarn install --frozen-lockfile + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + bundler-cache: true + + - name: Setup Git Config + run: | + git config user.name "GitHub Actions Bot" + git config user.email "<>" + + - name: Build and Upload to Firebase + uses: maierj/fastlane-action@v3.0.0 + with: + lane: 'android staging' + env: + # ANDROID_KEYSTORE_FILE: '${{ github.workspace }}/production.keystore' + # ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }} + # ANDROID_KEYSTORE_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }} + FIREBASE_ANDROID_APP_ID: ${{ secrets.FIREBASE_ANDROID_APP_ID }} + # Not required if you define service_credentials_file in the Fastfile + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + + - name: Archive build + uses: actions/upload-artifact@v4 + with: + name: staging_apk + path: android/app/build/outputs/apk/**/*.apk diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c40852e..03db2ef 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -30,21 +30,25 @@ end platform :android do - desc "Android assemble release version" - lane :android_staging do - increment_version_code(gradle_file_path: 'android/app/build.gradle') + desc "Android deploy to Firebase" + lane :staging do + latest_release = firebase_app_distribution_get_latest_release( + app: ENV["FIREBASE_ANDROID_APP_ID"] + ) + increment_version_code(gradle_file_path: 'android/app/build.gradle', version_code: latest_release[:buildVersion].to_i + 1) gradle(task: 'clean', project_dir: './android/') - gradle(task: 'assemble' ,build_type: 'Release', project_dir: './android') + gradle(task: 'assemble', build_type: 'Release', project_dir: './android') firebase_app_distribution( - app: "1:559995000649:android:828eba86aa6757c6beec98", - groups: "qa-test" - ) - git_commit(path: "./android", message: "Bump build version for Android") - push_to_git_remote - end + app: ENV["FIREBASE_ANDROID_APP_ID"], + groups: "qa-test", + firebase_cli_token: ENV["FIREBASE_TOKEN"] + # In your project use service_credentials_file instead of firebase_cli_token as it's a recommended solution + # service_credentials_file: File.absolute_path('../firebase-service-account.json'), + ) + end desc "Android bundle release version" - lane :android_release_bundle do + lane :release_bundle do increment_version_code(gradle_file_path: 'android/app/build.gradle') gradle(task: 'clean', project_dir: './android/') gradle(task: 'bundle' ,build_type: 'Release', project_dir: './android') diff --git a/fastlane/README.md b/fastlane/README.md index 8cc51d9..877f91c 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -28,18 +28,18 @@ iOS deploy to TestFlight ## Android -### android android_staging +### android staging ```sh -[bundle exec] fastlane android android_staging +[bundle exec] fastlane android staging ``` -Android assemble release version +Android deploy to Firebase -### android android_release_bundle +### android release_bundle ```sh -[bundle exec] fastlane android android_release_bundle +[bundle exec] fastlane android release_bundle ``` Android bundle release version