Bump version code for Android apps using GitHub Actions
Mike Yerou -
Play Store, since the beginning of time, had the same policy about versioning: every artifact uploaded and served from Play Store should have a unique version code. And this is a reasonable requirement for tracking reasons.
The only downside is that they leave the developer the responsibility of bumping and maintaining the version code. There's no way to "auto-increase" the version code. The version code is stored in the build.gradle file which means the codebase needs to be touched for the version code to be kept in sync with what you are uploading to the store.
To automate the process of bumping the version code and then committing the updated version to the codebase, we can have a GitHub Action (if you use GitHub; but the equivalent can be created for other sites) that does the "boring" work for us. More specifically, the process can be as follow:
Create a branch called bump/vX.Y.Z and push to remote.
The GitHub Action gets triggered and will create a PR that (1) sets the version name to X.Y.Z and (2) increases the version code by 1.
You can then review the PR to ensure that all the changes are correct, and proceed with the new release (see this post for automating the push-to-store process in GitHub).
Adjust the above script to your needs, and you have a semi-automated way of bumping version code before releasing without touching Android Studio.