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 date = new Date()
def formattedDate = date.format('yyyyMMdd')
return Integer.valueOf(formattedDate)
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return Integer.valueOf(stdout.toString().trim())
} catch (ignored) {
return null
}
}
android {
@@ -105,7 +112,7 @@ android {
if (variant.buildType.name == 'nightly') {
variant.outputs.all {
setVersionCodeOverride(versionCodeFromDate())
setVersionCodeOverride(getVersionCode())
setVersionNameOverride(getVersionName())
outputFileName = "${applicationId}_${variant.versionCode}.apk"
}