Publish apps updates like a PRO
Publishing an app update to Google Play store is not a very agile task. You need to access your developer console, choose the app you what to update, select release management, go to release dashboard, manage the release, … (I’m tired just for writing this).
There should be and there is a better way to publish your APK. Use the gradle-play-publisher.
This Gradle plugin is really useful when it comes to app publishing. You just need to edit your app on Android Studio, run a gradle task… and that’s it. The app is automatically published on Google Play Store!
Interested? Let’s check how to configure it 🛠
1. Setup Google API
In order to allow app publishing outside Google Play Console, you need to create a service account. So first step is to go to your Developer Console. Select Settings followed by API access.
Go all the way to the bottom and you will see a button: Create Service Account. Click on it and you will be prompted with:
Select Google API Console and you will be redirected to this screen:
From this point on, you will need to create a service account. Press: Create Service Account. A new screen will be shown with the steps to create one:
The first step is to add the account information, pretty straightforward. Next, you need to select the permissions through a role. Select App Engine Deployer to allow apps updates deployments.
Step three will allow you to create the account key. To create one, press Create Key, then choose a format, JSON is recommended. Store the downloaded file, it will be necessary further in this article.
Select done and your account is created 🎉
Now if you go back to your Google Play Console and refresh the API access page you will notice that a new service account is shown:
The only thing left is to grant the necessary permissions to your new service account. Click grant access. Select the role: Release Manager.
After you conclude the previous step your new API access should be fully operational. Next step, configure the gradle plugin in your Android Studio project.
2. Setup the Gradle Plugin
Start Android Studio. Open your root build.gradle file and add the following classpath reference:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:1.2.2'
}
}
Then add the gradle plugin to each individual com.android.application module where you want to use it. For example, app/build.gradle.
apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play'
Do you remember the key file you saved in step 1? Now it’s time to add it to your project. Place it for example inside the app/ folder. After adding it you need to reference the key path in your app/build.gradle:
play {
jsonFile = file('google-console.json') // path to your key
track = 'production' // upload to the production channel
}
The track represents where you what to publish you APK. If you didn’t add anything, it will be published into the alpha channel.
To introduce a changelog for the app update, it is required to add a new file.
To create a new play folder in your app/src/main. Add a whatsnew file. This file will contain the changes you made in your update. For example:
• Improvements for reliability and speed
All done! Just edit your version code and version number and run the task. Your app update will get published 🚀
3. Customize publishing
The plugins support a lot of customizations. Some of my favorites are:
track
is the target stage for an artifact, i.e. alpha/beta/prodreleaseStatus
is the type of release, i.e. draft/completed/in progressuserFraction
is the percentage of users who will receive a staged rollout
If you want to know more check out the documentation.
Thanks for reading this article. If you like it, please don’t forget to click 👏 to recommend it to others.
If you have any question send me a tweet @andrefrsousa!