2 stable releases
1.0.1 | Oct 28, 2023 |
---|
#42 in #play
23KB
456 lines
Google Play Tool
Introduction
This is a command line tool to enable you to upload Android .aab
bundle files to the Google Playstore as part of your automated build process. The goal is something similar to the xcrun altool
tool for iOS. It has some additional features to allow you to list the existing bundle versions and the available test tracks. It makes use of the Google Play Developer API.
After cargo install gplay
, run gplay --help
to see the available options. After your build completes you'll do something like this:
gplay upload --cred-file ~/.playstore/your-name-32f41bf78d1a.json --package-name com.your-name.your-app --bundle-file ./build/app/outputs/bundle/appRelease/app-release.aab --track-name internal
The tool uses the simple, non-restartable upload approach, so you will need to increase the timeout for large bundle files. The default timeout works well for bundles in the <50MB range on an 100Mbit network connection.
Setup
This tool uses the Google Play Android Developer API in Google Cloud to upload new bundle builds. Setting up Google Cloud is a bit overwhelming.
It is important to note how Google does app versioning. While your app will likely have a semantic version (major, minor, patch), each bundle build needs to have a unique integer version number, across all releases of the app. You cannot upload the same bundle version more than once. Bundle version numbers can be uploaded in any order, they just need to be unique. You'll need to figure out how this works in the context of your build and branching system.
Here is a general summary of the steps you will need to take.
- Go to Google Accounts and set up an account
- Go to the Google Play Console and set up a developer account
- Create your app, making a note of the package name, e.g. com.yourname.yourapp
- Upload build number
1
manually. If anyone from Google is reading this, this is an annoying restriction and should be fixed. - Go to the Google Cloud Console and enable the Google Play Android Developer API
- Create a service account in the Google Cloud Console
- Generate and download a
.json
containing the login credentials. Put it somewhere safe andchmod o=
to make sure only you have access. - Add the service account as a user in the Play Console. Give it all Releases permissions.
- Test everything out by running a
gplay list-bundles
command.
Once this is done you can use the upload
sub-command to upload your binaries to publish a new build to a given test track. Then you can go to the Play Console UI and move the build through the release tracks as needed.
Suggested Enhancements
Pull requests welcome for the following features:
- Support for re-startable uploads
- More Android Publisher API support
- Refactoring to improve the code
- Support for other methods of authentication
Dependencies
~20–35MB
~660K SLoC