Publishing to the Google Play Store with Fastlane and GitHub Actions

Why Fastlane?

  • Fastlane is the easiest way to automate beta deployments and releases for your iOS and Android apps. 🚀
  • It handles all tedious tasks, like generating screenshots, dealing with code signing, and releasing your application.

Generating Google Play Credentials

  • Open the Google Play Console
  • Go to Settings → API Access → Click ‘Create new service account’ and follow steps mentioned in a dialog.
  • In GCP console, Click ‘➕CREATE SERVICE ACCOUNT’
  • Provide service account name → Click ‘Create’
  • Then select role ‘Service Account User’ and click ‘Continue’.
  • Next step is optional so click ‘Done’.
  • Then you’ll see list of service accounts, Click Action menu of service account which you just created → Create Key → Select ‘Key Type’ as ‘JSON’ → Click ‘CREATE’
  • Then the credentials file will be downloaded to your machine. Keep that file safe.
  • Come back to the Play Console → Click ‘DONE’ on dialog. You’ll see service account which you just created.
  • Click “GRANT ACCESS’ → Select application which you want to allow to publish → Make sure you’ve checked ‘Releases’ section.
  • Finally, click ‘Apply’ → Click ‘Invite User’
  • Thus you’ve successfully set up Google play credentials. Keep that file with you and keep it safe.

Setup Fastlane in app

  • Copy the Credentials JSON file which is downloaded in the previous step in the root directory of your project and give it name (For e.g. play_config.json)
  • Then just run a command — sudo gem install fastlane
  • Setup Fastlane using command — fastlane init and provide information with respect to your app.
  • Appfile — Defines configuration information that is global to your app
  • Fastfile — Defines the "lanes" that drive the behaviour of Fastlane

Let’s create lanes

You can declare various lanes in Fastfile which can have different behaviours or simply we can call them tasks.

Setup GitHub Actions

As you might know that we always require a Keystore file (.jks)for signing APK/App Bundle before publishing app to the Google Play. You will also need Google play credentials file (.json) for deploying with Fastlane. If your project is in the private repository then you can easily include these files in VCS. But what if your project is opensource and you still you want to keep it secret? 🤔

base64 -i play_config.json > play_config.json.b64

Let’s create GitHub Action’s Workflow👨‍💻

  • Create a workflow file releaseProd.yml in .github/workflows directory. Add initial contents to the file as 👇
  • Install Ruby bundle
  • Now let’s create Keystore (.jks) file and Google play configuration (.json) file from content which we created using GitHub Actions Secret.
  • Finally, let’s execute the PROD lane

--

--

Coding Geek, Open Source Believer.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store