Skip to content

Instantly share code, notes, and snippets.

@designatednerd
Created December 16, 2015 21:31
Using the number of commits in the HEAD to auto-increment your android version count.
//Counts the number of commits on the HEAD of the repo.
def headCommitCount() {
def cmd = "git rev-list HEAD --count"
return cmd.execute().text.toInteger()
}
android {
defaultConfig {
versionCode headCommitCount() //Auto-increment the version based on how many commits have occurred.
versionName "x.x.x (" + versionCode + ")"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment