Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Last active August 16, 2019 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvareztech/2635580a83bd40b0025faa3a635de92a to your computer and use it in GitHub Desktop.
Save alvareztech/2635580a83bd40b0025faa3a635de92a to your computer and use it in GitHub Desktop.
Version bump gradle task
task bumperVersionPatch() {
group = 'bumper'
doLast {
def propertiesFile = file('gradle.properties')
def properties = new Properties()
properties.load(new FileInputStream(propertiesFile))
def versionName = properties['evaVersionName']
def versionCode = properties['evaVersionCode'].toInteger()
def major = (versionName =~ /\d+/)[0].toInteger()
def minor = (versionName =~ /\d+/)[1].toInteger()
def patch = (versionName =~ /\d+/)[2].toInteger()
// Save
properties['evaVersionName'] = "${major}.${minor}.${patch + 1}".toString()
properties['evaVersionCode'] = (versionCode + 1).toString()
properties.store(file('gradle.properties').newWriter(), null)
Process addProcess = ['git', 'add', 'app/gradle.properties'].execute(null, project.rootDir)
addProcess.waitForProcessOutput(System.out, System.err)
Process commitProcess = ['git', 'commit', "-m Internal Release ${versionName}"].execute(null, project.rootDir)
commitProcess.waitForProcessOutput(System.out, System.err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment