Two long-lived branches:
develop— the integration branch. Every change lands here first.main— released code only. Each release is a merge fromdevelop, taggedvX.Y.Z.
Nobody commits to develop or main directly; changes arrive through branches.
-
Cut a branch from
develop:git switch -c feature/<name> develop
-
Commit on the branch and keep
./gradlew :app:testDebugUnitTestgreen. -
Merge it into
developwith a merge commit, then delete the branch:git switch develop git merge --no-ff feature/<name> -m "Merge feature/<name> into develop" git branch -d feature/<name> git push origin develop git push origin --delete feature/<name> # only if the branch was pushed
If the merge goes through a pull request, use "Create a merge commit" and tick "Delete branch".
Release when enough changes have accumulated on develop. Freeze develop while doing it: no new
merges between the version bump and the release merge.
-
Check that
developis green:./gradlew :app:testDebugUnitTest :app:lintDebug
-
Bump the version on a short-lived branch. Edit
APP_VERSION_MAJOR,APP_VERSION_MINOR,APP_VERSION_PATCH(see VERSIONING.md) and increaseAPP_VERSION_CODEby one ingradle.properties:git switch -c release/X.Y.Z develop # edit gradle.properties git commit -am "Bump version to X.Y.Z" git switch develop git merge --no-ff release/X.Y.Z -m "Merge release/X.Y.Z into develop" git branch -d release/X.Y.Z
-
Merge
developintomainand tag the merge commit. Tags are annotated and follow the existing formRelease X.Y.Z (versionCode N):git switch main git merge --no-ff develop -m "Release X.Y.Z" git tag -a vX.Y.Z -m "Release X.Y.Z (versionCode N)"
A prerelease uses the suffix in both places, e.g.
0.2.0-betaandv0.2.0-beta. -
Bring
developlevel withmainso it contains the release commit and tag (a fast-forward, not a new commit):git switch develop git merge --ff-only main
-
Build the signed bundle from the tag and upload it to Google Play (see RELEASE_SIGNING.md):
git switch --detach vX.Y.Z ./gradlew :app:bundleRelease
-
Push everything:
git push origin main develop vX.Y.Z
A fix for an already released version follows the same path: a feature/<name> branch from
develop, merged into develop, then released as the next patch version.