Step by step tutorial to automate playstore app deployment using fastlane and google cloud

Step by step tutorial to automate playstore app deployment using fastlane and google cloud

Effortlessly upload Android Apps to Playstore using automation.

Fastlane is a tool that gives you command line interface to your Google Playstore developer account. This means you can build, sign and upload your app bundle to playstore from command line. In this article we teach you to create your build pipeline to achieve this.


Have you app ready and published first

This tutorial assumes that you already have a working app and you have uploaded and published it in play store the first time including all the graphics and other metadata.

I recommend you do this first step manually always to get a better understanding of all the steps that are needed. Some of these steps are about data safety and other legal items.

Create a google cloud account

Go to and create an account and create a project.

About Fastlane

Fastlane is a command line tool written in Ruby. It is meant to automate the entire deployment process of the app which includes screenshots, uploading APKs, signing code updating description, etc. It is the to-do tool today for all major companies to use.

If you want to install and run fastlane on your local computer then I recommend you try these steps.

This tutorial is not about using fastlane on your local computer but rather using Google Cloud to upload the API to playstore using Git commit hooks.

Automating App upload

The way this workflow would work is

  1. You as a developer write code and test it locally and deploy it to the Git repository.

  2. Github hook will inform Google Cloud that a new commit has been made and Google will trigger a build process.

  3. Google Cloud Build then decides to build your app from source and also invoke Fastlane command to upload it to Playstore.

This is a dumbed down and simplified version for individual developer.

In reality, a developer will checkin to a branch of release candidate which will create a real candidate APK which will be tested by either manual or automated QA and then branch will be merged with a production cut branch, which will then get built and uploaded to Playstore. But we hide that complexity here.

Creating a Dockerfile in you code repository

We create a Dockerfile in the code repository that describes the steps needed to build and upload the APK to playstore.

FROM mingc/android-build-box AS build
WORKDIR /home/gradle/src
RUN apt-get update
RUN apt-get install -y openssl
RUN apt-get install ruby
RUN gem install bundler
RUN gem install fastlane
COPY ../. /home/gradle/src
WORKDIR /home/gradle/src
RUN ./gradlew clean
RUN ./gradlew bundleKadambariRelease
RUN gem install bundler
RUN gem install fastlane
RUN gem environment
RUN gem which bundler
RUN PATH="$(ruby -e 'print Gem.default_dir')/bin:$PATH"
RUN fastlane supply --aab app/build/outputs/bundle/<MyAppName>Release/app-<my-app-name>-release.aab

Note that this Dockerfile is pretty large. It is possible to split it into smaller with a base image that has Android and Fastlane installed and second one which just builds the code. But I leave that upto you.

Add Fastlane files to your code repository

Fastlane requires you to create what is called a "Fastfile" and "Appfile" in your code repository. These files have most of the information Fastlane needs to upload it to your playstore account.

I recommend you install Fastlane on your local machine and run the following command to generate those files

fastlane init

It will ask you series of questions to set everything up.

Setting up your google credentials

  1. Open the Google Play Console

    1. Click Account Details, and note the Developer Account ID listed there
  2. Enable the Google Play Developer API by selecting an existing Google Cloud Project that fits your needs and pushing ENABLE

    1. If you don't have an existing project or prefer to have a dedicated one for fastlane, create a new one here and follow the instructions
  3. Open Service Accounts on Google Cloud and select the project you'd like to use

    1. Click the CREATE SERVICE ACCOUNT button at the top of the Google Cloud Platform Console page

    2. Verify that you are on the correct Google Cloud Platform Project by looking for the Developer Account ID from earlier within the light gray text in the second input, preceding, or by checking the project name in the navigaton bar. If not, open the picker in the top navigation bar, and find the right one.

    3. Provide a Service account name (e.g. fastlane-supply)

    4. Copy the generated email address that is noted below the Service account-ID field for later use

    5. Click DONE (don't click CREATE AND CONTINUE as the optional steps such as granting access are not needed):

    6. Click on the Actions vertical three-dot icon of the service account you just created

    7. Select Manage keys on the menu

    8. Click ADD KEY โ†’ Create New Key

    9. Make sure JSON is selected as the Key type, and click CREATE

    10. Save the file on your computer when prompted and remember where it was saved at

  4. Open the Google Play Console and select Users and Permissions

    1. Click Invite new users

    2. Paste the email address you saved for later use into the email address field

    3. Click on Account Permissions

    4. Choose the permissions you'd like this account to have. We recommend Admin (all permissions), but you may want to manually select all checkboxes and leave out some of the Releases permissions such as Release to production, exclude devices, and use Play App Signing

    5. Click on Invite User

You can use fastlane run validate_play_store_json_key json_key:/path/to/your/downloaded/file.json to test the connection to Google Play Store with the downloaded private key. Once that works, add the path to the JSON file to your Appfile:


The path is relative to where you normally run fastlane.

Configure supply

Edit your fastlane/Appfile and change the json_key_file line to have the path to your credentials file:

json_key_file "/path/to/your/downloaded/key.json"

Fetch your app metadata

If your app has been created on the Google Play developer console, you're ready to start using supply to manage it! Run:

fastlane supply init

and all of your current Google Play store metadata will be downloaded to fastlane/metadata/android.

Setting up Google Cloud Build Trigger

Now that you have both Dockerfile and Fastlane's Fastfile and Appfile setup, it is time to setup Google Cloud Build Trigger.

A detailed and up to date tutorial is available here.

All you have to do is click on "New Trigger" connect your Github Repository to Google Cloud and then select Dockerfile as the build input. Then you are in business.

Is it all work

As soon as you make a Git commit and push it, the Google Trigger will do rest of the job. Initially you might see failures and that is fine. You can update your Dockerfile based on the logs provided by Google Cloud build.

Did you find this article valuable?

Support Android Authority by becoming a sponsor. Any amount is appreciated!