Skip to content

Instantly share code, notes, and snippets.

@luciofm
Created December 2, 2015 14:59
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save luciofm/923a9f35f2175dda7ad7 to your computer and use it in GitHub Desktop.
Save luciofm/923a9f35f2175dda7ad7 to your computer and use it in GitHub Desktop.
Auto increment version number on release builds... You can change the build type on versionCode.gradle, you also will need to commit and push gradle.properties on your CI
apply from: 'versionCode.gradle'
android {
defaultConfig {
versionName VERSION_NAME
versionCode Integer.parseInt(VERSION_CODE)
}
}
VERSION_NAME=1.0.0
VERSION_CODE=10
task('increaseVersionCode') << {
def versionCode = Integer.parseInt(VERSION_CODE) + 1
ant.propertyfile(file: "../gradle.properties") {
entry(key: "VERSION_CODE", value: versionCode)
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig) {
task.dependsOn 'increaseVersionCode'
}
}
@Stormwind99
Copy link

Stormwind99 commented Jul 6, 2018

I wrote a simple non-Android version that only increments a build number - hope someone finds it useful.

@SUPERCILEX
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment