-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathversioning.gradle
More file actions
39 lines (33 loc) · 1.32 KB
/
versioning.gradle
File metadata and controls
39 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Used to update Build Number and Commit Changes to Repository
* */
def getVersionProps() {
def versionPropsFile = file('gradle.properties')
if (!versionPropsFile.exists()) {
versionPropsFile.createNewFile()
}
def versionProps = new Properties()
versionPropsFile.withInputStream {versionProps.load(it) }
return versionProps
}
private void commitSemanticRelease(versionName) {
Process addChanges = ['git', 'add', 'gradle.properties'].execute(null, project.rootDir)
addChanges.waitForProcessOutput(System.out, System.err)
Process createCommit = ['git', 'commit', "-m Release ${versionName}"].execute(null, project.rootDir)
createCommit.waitForProcessOutput(System.out, System.err)
}
private def getAppVersionCode() { getVersionProps()['appVersionCode'].toInteger() }
private void saveSemanticRelease(versionName) {
def versionProps = getVersionProps()
versionProps['appVersionName'] = versionName
versionProps['appVersionCode'] = (getAppVersionCode() + 1).toString()
versionProps.store(file('gradle.properties').newWriter(), null)
commitSemanticRelease(versionName)
}
task bumperSemanticRelease() {
group = 'bumper'
doLast {
def versionName = project.hasProperty('bumperVersionName') ? bumperVersionName : '1.0.0'
saveSemanticRelease(versionName)
}
}