Skip to content
Draft
57 changes: 57 additions & 0 deletions .github/workflows/playstore-internal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish to Play Store Internal Track

on:
workflow_dispatch:
push:
branches: [ 'release/**' ]

# Cancel any in-progress runs of this workflow if a new run is triggered within the same branch or PR
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
build:
runs-on: macos-latest # use [ self-hosted, macOS ] to host on our own mac mini, which is twice as fast and cheaper than hosting on a github runner. See README for more info.
steps:
- uses: actions/checkout@v4
- name: Prepare Release
uses: ./.github/actions/prepare-release

# This will decode the keystore from base 64 text representation that we have stored in secrets
# and generates a keystore file and gets stored in /android-app path
- name: Decode Keystore
env:
ENCODED_STRING: ${{ secrets.KEYSTORE_BASE_64 }}
shell: bash
run: |
echo $ENCODED_STRING > keystore-b64.txt
base64 -d <keystore-b64.txt >upload-keystore.jks
# The secrets.gradle file that is stored as text, does not need to be decoded
# and can be directly written to a file
# This file is used by the gradle build to sign the AAB
- name: Create secrets.gradle
run: echo "${{ secrets.SECRETS_GRADLE }}" > secrets.gradle

- name: Build Prod Release Bundle
run: ./gradlew bundleProdRelease --stacktrace

- name: Upload Release Bundle to Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}-${{ github.run_number }}-prod-release-bundle
path: |
${{ github.workspace }}/app/build/outputs/bundle/prodRelease/app-prod-release.aab

- name: Upload to Play Store Internal Track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_SERVICE_ACCOUNT_JSON }}
packageName: nl.q42.template # TODO: Update this to match your app's package name
releaseFiles: ${{ github.workspace }}/app/build/outputs/bundle/prodRelease/app-prod-release.aab
track: internal
status: completed
inAppUpdatePriority: 2
18 changes: 18 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ A template for creating Android projects at Q42.
described
in [self hosted runner](#self-hosted-runner), when using Github Actions.
1. Setup/adjust uploads to [Firebase app distribution](#firebase-app-distribution).
1. If using Play Store deployment, update the `packageName` in [playstore-internal.yml](.github/workflows/playstore-internal.yml) to match your package name (the rename-project.py script does not update workflow files).
1. Build your awesome project :-)
1. Consider contributing to this template when you find something that could be improved.

Expand Down Expand Up @@ -81,6 +82,8 @@ This project uses Github Actions for CI. We have added these workflows for now:

- _debug.yml_: any commit on any branch triggers a `devDebug` apk and a `prodDebug` apk build
- _release.yml_: any PR triggers signed release builds (`prodRelease` bundle and `prodRelease` apk)
- _firebase-app-distribution.yml_: any PR to develop triggers a release build that is uploaded to Firebase App Distribution
- _playstore-internal.yml_: any push to a release branch triggers a release build that is uploaded to Play Store Internal Test track

#### Adding your own keystore's details on Github Actions

Expand Down Expand Up @@ -124,6 +127,21 @@ With the default configuration, all commits on develop will be pushed to Firebas
To also make these available to a test group, you can enable the `groups` parameter in the
[firebase yml](.github/workflows/firebase-app-distribution.yml) file.

#### Play Store deployment

We use the [upload-google-play github action](https://github.com/r0adkll/upload-google-play) in our github actions setup to automatically upload release builds to the Play Store Internal Test track.

To enable this for your own app, you need to:

1. Create a service account in Google Cloud Console with access to the Google Play Developer API
2. Download the service account JSON key file
3. Add the content of the JSON file to your Github repository secrets as `PLAYSTORE_SERVICE_ACCOUNT_JSON`
4. Update the `packageName` in the [playstore-internal.yml](.github/workflows/playstore-internal.yml) file to match your app's package name

More details on creating a service account can be found in the [upload-google-play documentation](https://github.com/r0adkll/upload-google-play?tab=readme-ov-file#configure-access-via-service-account).

With the default configuration, all commits to release branches (release/*) will be pushed to the Play Store Internal Test track.

#### Self-hosted runner

You can run the worlkflows on our self-hosted runner (a mac mini). This is:
Expand Down