Preparing for Automatic Publishing of Android Apps in Play Store
I spent this week searching through libraries and services which provide a way to publish built apks directly through API so that the repositories for Android apps can trigger publishing automatically after each push on master branch. The projects to be auto-deployed are:
I had eyes on fastlane for a couple of months and it came out to be the best solution for the task. The tool not only allows publishing of APK files, but also Play Store listings, screenshots, and changelogs. And that is only a subset of its capabilities bundled in a subservice supply.
There is a process before getting started to use this service, which I will go through step by step in this blog. The process is also outlined in the README of the supply project.
Enabling API Access
The first step in the process is to enable API access in your Play Store Developer account if you haven’t done so. For that, you have to open the Play Dev Console and go to Settings > Developer Account > API access.
If this is the first time you are opening it, you’ll be presented with a confirmation dialog detailing about the ramifications of the action and if you agree to do so. Read carefully about the terms and click accept if you agree with them. Once you do, you’ll be presented with a setting panel like this:
Creating Service Account
As you can see there is no registered service account here and we need to create one. So, click on CREATE SERVICE ACCOUNT button and this dialog will pop up giving you the instructions on how to do so:
So, open the highlighted link in the new tab and Google API Console will open up, which will look something like this:
Click on Create Service Account and fill in these details:
Account Name: Any name you want
Role: Project > Service Account Actor
And then, select Furnish a new private key and select JSON. Click CREATE.
A new JSON key will be created and downloaded on your device. Keep this secret as anyone with access to it can at least change play store listings of your apps if not upload new apps in place of existing ones (as they are protected by signing keys).
Now return to the Play Console tab (we were there in Figure 2 at the start of Creating Service Account), and click done as you have created the Service Account now. And you should see the created service account listed like this:
Now click on grant access, choose Release Manager from Role dropdown, and select these PERMISSIONS:
Of course you don’t want the fastlane API to access financial data or manage orders. Other than that it is up to you on what to allow or disallow. Same choice with expiry date as we have left it to never expire. Click on ADD USER and you’ll see the Release Manager created in the user list like below:
Now you are ready to use the fastlane service, or any other release management service for that matter.
Install fastlane by
sudo gem install fastlane
Go to your project folder and run
fastlane supply init
First it will ask the location of the private key JSON file you downloaded, and then the package name of the application you are trying to initialize fastlane for.
Then it will create metadata folder with listing information excluding the images. So you’ll have to download and place the images manually for the first time
After modifying the listing, images or APK, run the command:
fastlane supply run
That’s it. Your app along with the store listing has been updated!
This is a very brief introduction to the capabilities of the supply service. All interactive options can be supplied via command line arguments, certain parts of the metadata can be omitted and alpha beta management along with release rollout can be done in steps! Make sure to check out the links below:
- Fastlane Supply Repo
- Fastlane Repo
- Fastlane Official Documentation
You must be logged in to post a comment.