Change versionCode for nightlies to commit count
@@ -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"
}
