Deploying Android Apps Using GitHub Actions

May 4 2023 · Kotlin 1.7.21, Android 13, Android Studio Electric Eel

Part 1: Automate Releases with GitHub Actions

09. Release to the Google Play Store

Episode complete

About this episode

Leave a rating/review

See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 08. Authenticate with Google Play Console

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 09. Release to the Google Play Store

Try writing a changelog for different releases of your app and upload it along with the APK. You can find out more at https://github.com/r0adkll/upload-google-play

Transcript: 09. Release to the Google Play Store

To upload a build to the Play Store Console, use the r0adkll/upload-google-play action.

You want to deploy to the Play Store only when you push a commit to the master branch.

Job to Upload to Google Play

To do this, create a new file named play_store_workflow.yml under .github/workflows and add the following code to it:

name: Deploy to Play Store

on:
  push:
    branches:
      - master

jobs:

Then, the build job from check_and_deploy.yml and paste it inside this file.

With the build job in place, you can now create a job to upload the signed AAB to the Play Store.

Add the following code:

  deploy-play-store:
    needs: [build]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v3
        with:
          name: release.aab
      - uses: actions/download-artifact@v3
        with:
          name: mapping.txt
      - name: Publish to Play Store internal test track
        uses: r0adkll/upload-google-play@v1.1.1
        with:
          serviceAccountJsonPlainText: ${{ secrets.PLAY_SERVICE_ACCOUNT_JSON }}
          packageName: com.yourcompany.android.quotes
          releaseFiles: app-release-signed.aab
          track: internal
          changesNotSentForReview: true
          mappingFile: mapping.txt

The workflow triggers when you push any change to the master branch. The build job is the same as the one you used in the previous workflow.

The deploy-play-store job does the following:

  1. Downloads the release APK and mapping file using the actions/download-artifact action.
  2. Uploads the APK to the internal track and makes it available to 50% of the users on that track.
  3. Specifies the package name of the app and also the APK and mapping file to upload.

Commit this file and push it to GitHub.

Verify the Uploaded Build

To verify the workflow, push an empty commit to the master branch.

git commit --allow-empty -m "Empty commit"
git push origin master

Once the workflow is complete, visit the Internal track on the Google Play Console.

You’ll see that a build of the app has been published.

If you get an error stating that the package name is already in use on the Play Store:

  1. Open app/build.gradle
  2. Change the applicationId to something specific to your project.

Additionally, remember to register a new app on Firebase App Distribution and update the package name in the action as well.

Congratulations, you’ve successfully built a complete continuous delivery pipeline using GitHub Actions.