diff --git a/.github/workflows/reusable-android-google-play-publish.yaml b/.github/workflows/reusable-android-google-play-publish.yaml new file mode 100644 index 0000000..1949808 --- /dev/null +++ b/.github/workflows/reusable-android-google-play-publish.yaml @@ -0,0 +1,106 @@ +name: Reusable Android Demo Shop 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 + KEYSTORE_AS_BASE64: + 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_and_version_bump: + 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.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 + playJson=$(cat google-play-service-account.json) + echo "playJson=$playJson" >> $GITHUB_OUTPUT + + # Building release bundle + - 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 }} + + # Sending to Google Play + - name: Deploy to Google Play Internal Testing + uses: r0adkll/upload-google-play@v1 + with: + 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: | + version=$(grep "VERSION_NAME=" ${{ inputs.PROPERTIES_FILE }} | cut -d'=' -f2) + echo "versionName=$version" >> $GITHUB_ENV + echo "versionName=$version" >> $GITHUB_OUTPUT + + # Commit changes + - 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 }}