Version Orchestrator provides an effortless and performant way to automate versioning your Android app.
Version Orchestrator looks at your Git history to compute a version code and name for your app.
The version code is a combination of the number of commits in your repository and your tag history, enabling support for hotfix releases. The math looks a little like this:
versionCode = existingAppOffset +
commitCount +
numberOfNonPatchTags +
100 * numberOfNonPatchTagsMinusOneIfIsRelease
For example, you have 4 commits and tag a 1.0.0
release (versionCode = 5
). On your
5th commit, the version code will jump to 106
. You continue making commits until you realize a
critical bug needs to be fixed. Branching off the 1.0.0
release, you fix the bug and tag your
1.0.1
hotfix (versionCode = 6
). After merging the hotfix and 3 other commits from your new
features back into master, you create a 1.1.0
release (versionCode = 110
). On your 11th commit,
the version code will jump to 211
. This continues on, allowing you to make 100 patch releases for
each major or minor release.
The version name is a combination of the latest tag, commit hash, dirtiness flag, and variant name.
Currently, it is calculated using git describe
and your buildType
name plus productFlavor
name (if present).
Apply the plugin to each individual com.android.application
module where you want to use Version
Orchestrator through the plugins {}
DSL:
Kotlin
plugins {
id("com.android.application")
id("com.supercilex.gradle.versions") version "0.10.0"
}
Groovy
plugins {
id 'com.android.application'
id 'com.supercilex.gradle.versions' version '0.10.0'
}
If you're prepared to cut yourself on the bleeding edge of Version Orchestrator development,
snapshot builds are available from
Sonatype's snapshots
repository:
Kotlin
buildscript {
repositories {
// ...
maven("https://oss.sonatype.org/content/repositories/snapshots")
}
dependencies {
// ...
classpath("com.supercilex.gradle:version-orchestrator:1.0.0-SNAPSHOT")
}
}
Groovy
buildscript {
repositories {
// ...
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
}
dependencies {
// ...
classpath 'com.supercilex.gradle:version-orchestrator:1.0.0-SNAPSHOT'
}
}
Version Orchestrator offers several options to fit your use case.
To handle version codes yourself, disable version code configuration:
versionOrchestrator {
configureVersionCode.set(false)
}
To handle version names yourself, disable version name configuration:
versionOrchestrator {
configureVersionName.set(false)
}
To make debug builds as fast as possible, version codes and names are never changed in debug builds by default. To enable versioning, enable debug build configuration:
versionOrchestrator {
configureDebugBuilds.set(true)
}
If your app already has an established version code, you can tell Version Orchestrator about it:
versionOrchestrator {
versionCodeOffset.set(123)
}