Change versionCode for nightlies to commit count

This commit is contained in:
Peter Storch
2021-11-20 23:04:12 +01:00
parent 681058c3e6
commit 54f1690478
+12 -5
View File
@@ -30,10 +30,17 @@ def getVersionName = { ->
} }
} }
def versionCodeFromDate = { -> def getVersionCode = { ->
def date = new Date() try {
def formattedDate = date.format('yyyyMMdd') def stdout = new ByteArrayOutputStream()
return Integer.valueOf(formattedDate) exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return Integer.valueOf(stdout.toString().trim())
} catch (ignored) {
return null
}
} }
android { android {
@@ -105,7 +112,7 @@ android {
if (variant.buildType.name == 'nightly') { if (variant.buildType.name == 'nightly') {
variant.outputs.all { variant.outputs.all {
setVersionCodeOverride(versionCodeFromDate()) setVersionCodeOverride(getVersionCode())
setVersionNameOverride(getVersionName()) setVersionNameOverride(getVersionName())
outputFileName = "${applicationId}_${variant.versionCode}.apk" outputFileName = "${applicationId}_${variant.versionCode}.apk"
} }