Skip to content
Sk Niyaj Ali edited this page Jul 24, 2024 · 3 revisions

In this project, we've configured Fastlane and the Google-play-publisher plugin to test and release the app to the Play Store.

The first APK or App Bundle needs to be uploaded via the Google Play Console because registering the app with the Play Store cannot be done using the Fastlane or Play Developer API. For all subsequent uploads and changes, these tools may be used.

We've configured both tools for local testing and the GitHub workflow for automated deployments. This setup allows for a streamlined process to build and deploy the app to the Google Play Store.

Since we haven't tested it with production data, it may not work as expected, some tweaks in configuration should be applied.


We've configured Fastlane in CLI and GitHub Workflow, to use this follow the below steps.

  • Update your app's version code and name if necessary.
  • Please prepare release notes or changelog if needed.
  • Update the bash script(playstore_release.sh) with correct paths and credentials.
  • Run the bash script to set environment variables.
  • Execute fastlane supply to fetch data from Play Store.
  • Execute fastlane locally by using fastlane deploy.

To use this workflow:

Create all the required secrets in your GitHub repository settings. Ensure your Fastfile (fastlane configuration) has the appropriate lanes for testing and deployment.

Required GitHub Secrets:

  • GPLAY_SERVICE_ACCOUNT_KEY: Base64 encoded Google Play Service Account key file
  • STAGING_KEYSTORE_FILE: Base64 encoded Android keystore file
  • STAGING_KEYSTORE_PASSWORD: Password for the Android keystore
  • STAGING_KEY_ALIAS: Alias for the key in the keystore
  • STAGING_KEY_PASSWORD: Password for the key in the keystore
  • STAGING_PACKAGE_NAME: Package name for your staging Android app

Workflow Details:

Trigger: The workflow runs on pushes to the "release" branch.

Job: deploy Runs on ubuntu-latest

Steps:

  • Checkout code
  • Set up Ruby 2.7.2 with bundler cache
  • Run tests using fastlane
  • Create Google Play Service Account Key file
  • Create Keystore file
  • Deploy Android release using fastlane
  • Upload build artifacts

Gradle Play Publisher (GPP) is Android's unofficial release automation Gradle Plugin. It can do anything from building, uploading, and then promoting your App Bundle or APK to publishing app listings and other metadata.

Setup

After you've gone through the Service Account setup, you should have a JSON file with your private key. Add a play block alongside your android one with the file's location:

android { ... }

play {
    serviceAccountCredentials.set(file("your-key.json"))
}

Managing artifacts

GPP supports uploading both the App Bundle and APK. Once uploaded, GPP also supports promoting those artifacts to different tracks.

Example configuration:

play {
    track.set("production")
    userFraction.set(0.5)
    updatePriority.set(2)
    releaseStatus.set(ReleaseStatus.IN_PROGRESS)
}

Managing Play Store metadata

GPP supports uploading any metadata you might want to change with each release, from screenshots and descriptions to in-app purchases and subscriptions. GPP includes a bootstrap task that pulls down your existing listing and initializes everything for you. To use it, run ./gradlew bootstrapListing.

Publishing listings

Run ./gradlew publishListing.

Publishing an App Bundle

Run ./gradlew publishBundle.