From 316edfae2c82091b1d91c23ba6108e83ef004fce Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Thu, 17 Oct 2024 16:48:41 +0200 Subject: [PATCH 1/4] feat: Added reusable-android-demo-shop-publish.yaml --- .../reusable-android-demo-shop-publish.yaml | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/reusable-android-demo-shop-publish.yaml diff --git a/.github/workflows/reusable-android-demo-shop-publish.yaml b/.github/workflows/reusable-android-demo-shop-publish.yaml new file mode 100644 index 0000000..eba36f9 --- /dev/null +++ b/.github/workflows/reusable-android-demo-shop-publish.yaml @@ -0,0 +1,94 @@ +name: Reusable Android Publish + +on: + workflow_call: + inputs: + packageName: + required: true + type: string + releaseFiles: + required: true + type: string + PROPERTIES_FILE: + required: true + type: string + secrets: + PLAY_ACCOUNT_AS_BASE64: + required: true + SIGNING_STORE_FILE: + required: true + SIGNING_STORE_PASSWORD: + required: true + SIGNING_KEY_ALIAS: + required: true + SIGNING_KEY_PASSWORD: + required: true + GITHUB_APP_ID: + required: true + GITHUB_APP_PRIVATE_KEY: + required: true + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/create-github-app-token@v1 + id: app-token + with: + app-id: ${{ secrets.GITHUB_APP_ID }} + private-key: ${{ secrets.GITHUB_APP_PRIVATE_KEY }} + + - name: Checkout repository + uses: actions/checkout@v4 + with: + token: ${{ steps.app-token.outputs.token }} + + - name: Set up JDK 20 + uses: actions/setup-java@v4 + with: + java-version: '20' + distribution: 'zulu' + + - name: Create Keystore file + run: | + echo "${{ secrets.SIGNING_STORE_FILE }}" | base64 --decode > app/keystore.jks + + - name: Build Release AAB + run: ./gradlew bundleProdRelease + env: + SIGNING_STORE_FILE: app/keystore.jks + SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }} + SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} + SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + + - name: Deploy to Google Play Internal Testing + uses: r0adkll/upload-google-play@v1 + with: + serviceAccountJsonPlainText: ${{ secrets.PLAY_ACCOUNT_AS_BASE64 }} + packageName: ${{ inputs.packageName }} + releaseFiles: ${{ inputs.releaseFiles }} + track: "internal" + + - name: Bump version + run: ./gradlew incrementVersion + env: + PROPERTIES_FILE: ${{ inputs.PROPERTIES_FILE }} + + - name: Retrieve new version + id: versionName + run: | + version=$(grep "VERSION_NAME=" ${{ inputs.PROPERTIES_FILE }} | cut -d'=' -f2) + echo "versionName=$version" >> $GITHUB_ENV + echo "versionName=$version" >> $GITHUB_OUTPUT + + - name: Commit changes + id: committer + uses: planetscale/ghcommit-action@v0.1.44 + env: + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} + with: + repo: ${{ github.repository }} + branch: master + commit_message: 'chore: bump version to ${{ steps.versionName.outputs.versionName }}' + file_pattern: ${{ inputs.PROPERTIES_FILE }} From ef911008e7595b31a944412f9f48c7b7c3f0c3b5 Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Fri, 18 Oct 2024 12:08:41 +0200 Subject: [PATCH 2/4] feat: Added decoding file from json and rename flow --- ...reusable-android-google-play-publish.yaml} | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) rename .github/workflows/{reusable-android-demo-shop-publish.yaml => reusable-android-google-play-publish.yaml} (82%) diff --git a/.github/workflows/reusable-android-demo-shop-publish.yaml b/.github/workflows/reusable-android-google-play-publish.yaml similarity index 82% rename from .github/workflows/reusable-android-demo-shop-publish.yaml rename to .github/workflows/reusable-android-google-play-publish.yaml index eba36f9..c7302cf 100644 --- a/.github/workflows/reusable-android-demo-shop-publish.yaml +++ b/.github/workflows/reusable-android-google-play-publish.yaml @@ -1,4 +1,4 @@ -name: Reusable Android Publish +name: Reusable Android Demo Shop Publish on: workflow_call: @@ -15,7 +15,7 @@ on: secrets: PLAY_ACCOUNT_AS_BASE64: required: true - SIGNING_STORE_FILE: + KEYSTORE_AS_BASE64: required: true SIGNING_STORE_PASSWORD: required: true @@ -29,7 +29,7 @@ on: required: true jobs: - publish: + publish_and_version_bump: runs-on: ubuntu-latest steps: @@ -52,8 +52,13 @@ jobs: - name: Create Keystore file run: | - echo "${{ secrets.SIGNING_STORE_FILE }}" | base64 --decode > app/keystore.jks + echo "${{ secrets.KEYSTORE_AS_BASE64 }}" | base64 --decode > app/keystore.jks + - name: Decode Google Play service account JSON + run: | + echo "${{ secrets.PLAY_ACCOUNT_AS_BASE64 }}" | base64 --decode > google-play-service-account.json + + # Building release bundle - name: Build Release AAB run: ./gradlew bundleProdRelease env: @@ -62,19 +67,22 @@ jobs: SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }} SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + # Sending to Google Play - name: Deploy to Google Play Internal Testing uses: r0adkll/upload-google-play@v1 with: - serviceAccountJsonPlainText: ${{ secrets.PLAY_ACCOUNT_AS_BASE64 }} + serviceAccountJsonPlainText: ${{ steps.decode.outputs.playJson }} packageName: ${{ inputs.packageName }} releaseFiles: ${{ inputs.releaseFiles }} track: "internal" + # Increment version - name: Bump version run: ./gradlew incrementVersion env: PROPERTIES_FILE: ${{ inputs.PROPERTIES_FILE }} + # Getting new version - name: Retrieve new version id: versionName run: | @@ -82,6 +90,7 @@ jobs: echo "versionName=$version" >> $GITHUB_ENV echo "versionName=$version" >> $GITHUB_OUTPUT + # Commit changes - name: Commit changes id: committer uses: planetscale/ghcommit-action@v0.1.44 From 1fd73747bb98837bc9a6fcd6603e7d0dff1a54ff Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Fri, 18 Oct 2024 13:43:53 +0200 Subject: [PATCH 3/4] feat: Added decoding of Google Play service account JSON and output playJson for subsequent steps --- .github/workflows/reusable-android-google-play-publish.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/reusable-android-google-play-publish.yaml b/.github/workflows/reusable-android-google-play-publish.yaml index c7302cf..2502283 100644 --- a/.github/workflows/reusable-android-google-play-publish.yaml +++ b/.github/workflows/reusable-android-google-play-publish.yaml @@ -55,8 +55,10 @@ jobs: echo "${{ secrets.KEYSTORE_AS_BASE64 }}" | base64 --decode > app/keystore.jks - name: Decode Google Play service account JSON + id: decode run: | echo "${{ secrets.PLAY_ACCOUNT_AS_BASE64 }}" | base64 --decode > google-play-service-account.json + echo "::set-output name=playJson::$(cat google-play-service-account.json)" # Building release bundle - name: Build Release AAB From f081ec9353538dc325518718054cc4424477b45c Mon Sep 17 00:00:00 2001 From: Daniel Green Date: Fri, 18 Oct 2024 14:02:06 +0200 Subject: [PATCH 4/4] feat: Replaced deprecated set-output syntax with method using GITHUB_OUTPUT --- .github/workflows/reusable-android-google-play-publish.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-android-google-play-publish.yaml b/.github/workflows/reusable-android-google-play-publish.yaml index 2502283..1949808 100644 --- a/.github/workflows/reusable-android-google-play-publish.yaml +++ b/.github/workflows/reusable-android-google-play-publish.yaml @@ -58,7 +58,8 @@ jobs: id: decode run: | echo "${{ secrets.PLAY_ACCOUNT_AS_BASE64 }}" | base64 --decode > google-play-service-account.json - echo "::set-output name=playJson::$(cat google-play-service-account.json)" + playJson=$(cat google-play-service-account.json) + echo "playJson=$playJson" >> $GITHUB_OUTPUT # Building release bundle - name: Build Release AAB