From e31fb014106fc76150b697d6d02fd0f1e86a3172 Mon Sep 17 00:00:00 2001 From: Zane Schepke Date: Sat, 20 Jan 2024 20:17:56 -0500 Subject: [PATCH] ci: add pre-release pipeline Change release pipeline to deploy to production google play --- .github/workflows/pre-release.yml | 86 +++++++++++++++++++ .../workflows/{android.yml => release.yml} | 7 +- fastlane/Fastfile | 12 +++ 3 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/pre-release.yml rename .github/workflows/{android.yml => release.yml} (96%) diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml new file mode 100644 index 0000000..7081fc4 --- /dev/null +++ b/.github/workflows/pre-release.yml @@ -0,0 +1,86 @@ +# name of the workflow +name: Android CI Tag Deployment (Pre-release) + +on: + push: + tags: + - '*.*.*-**' + +jobs: + build: + name: Build Signed APK + + runs-on: ubuntu-latest + + env: + KEY_STORE_PATH: ${{ secrets.KEY_STORE_PATH }} + SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '17' + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + # Here we need to decode keystore.jks from base64 string and place it + # in the folder specified in the release signing configuration + - name: Decode Keystore + id: decode_keystore + uses: timheuer/base64-to-file@v1.2 + with: + fileName: 'android_keystore.jks' + fileDir: ${{ github.workspace }}/app/keystore/ + encodedString: ${{ secrets.KEYSTORE }} + + - name: Create service_account.json + id: createServiceAccount + run: echo '${{ secrets.SERVICE_ACCOUNT_JSON }}' > service_account.json + + # Build and sign APK ("-x test" argument is used to skip tests) + # add fdroid flavor for apk upload + - name: Build Fdroid Release APK + run: ./gradlew :app:assembleFdroidRelease -x test + + # get fdroid flavor release apk path + - name: Get apk path + id: apk-path + run: echo "path=$(find . -regex '^.*/build/outputs/apk/fdroid/release/.*\.apk$' -type f | head -1)" >> $GITHUB_OUTPUT + + # Save the APK after the Build job is complete to publish it as a Github release in the next job + - name: Upload APK + uses: actions/upload-artifact@v4.2.0 + with: + name: wgtunnel + path: ${{ steps.apk-path.outputs.path }} + - name: Download APK from build + uses: actions/download-artifact@v4 + with: + name: wgtunnel + - name: Create Release with Fastlane changelog notes + id: create_release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + # fix hardcode changelog file name + body_path: ${{ github.workspace }}/fastlane/metadata/android/en-US/changelogs/33400.txt + tag_name: ${{ github.ref_name }} + name: ${{ github.ref_name }} + draft: false + prerelease: true + files: ${{ github.workspace }}/${{ steps.apk-path.outputs.path }} + - name: Deploy with fastlane + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' # Not needed with a .ruby-version file + bundler-cache: true + - name: Distribute app to Beta track 🚀 + run: (cd ${{ github.workspace }} && bundle install && bundle exec fastlane beta) + diff --git a/.github/workflows/android.yml b/.github/workflows/release.yml similarity index 96% rename from .github/workflows/android.yml rename to .github/workflows/release.yml index 3808ed4..73fc619 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,5 @@ # name of the workflow -name: Android CI Tag Deployment +name: Android CI Tag Deployment (Release) on: push: @@ -78,7 +78,7 @@ jobs: # fix hardcode changelog file name body_path: ${{ github.workspace }}/fastlane/metadata/android/en-US/changelogs/33400.txt tag_name: ${{ github.ref_name }} - name: Release ${{ github.ref_name }} + name: ${{ github.ref_name }} draft: false prerelease: false files: ${{ github.workspace }}/${{ steps.apk-path.outputs.path }} @@ -87,7 +87,6 @@ jobs: with: ruby-version: '3.2' # Not needed with a .ruby-version file bundler-cache: true - - name: Distribute app to Beta track 🚀 - run: (cd ${{ github.workspace }} && bundle install && bundle exec fastlane beta) + run: (cd ${{ github.workspace }} && bundle install && bundle exec fastlane production) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 7ab1810..829eb37 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -2,6 +2,18 @@ default_platform(:android) platform :android do + desc 'Deploy a new internal version to the Google Play Store' + lane :internal do + gradle(task: "clean bundleGeneralRelease") + upload_to_play_store(track: 'internal', skip_upload_apk: true) + end + + desc "Deploy an alpha version to the Google Play" + lane :alpha do + gradle(task: "clean bundleGeneralRelease") + upload_to_play_store(track: 'alpha', skip_upload_apk: true) + end + desc "Deploy a beta version to the Google Play" lane :beta do gradle(task: "clean bundleGeneralRelease")