F-Droid: fix the "-dev" issue in version name (#815)

This commit is contained in:
Benoit Marty 2020-01-20 15:58:12 +01:00
parent d1699279fe
commit f5e6b4b857
3 changed files with 24 additions and 5 deletions

View file

@ -9,6 +9,8 @@
<w>decryptor</w> <w>decryptor</w>
<w>emoji</w> <w>emoji</w>
<w>emojis</w> <w>emojis</w>
<w>fdroid</w>
<w>gplay</w>
<w>hmac</w> <w>hmac</w>
<w>ktlint</w> <w>ktlint</w>
<w>linkified</w> <w>linkified</w>

View file

@ -17,7 +17,7 @@ Translations 🗣:
- -
Build 🧱: Build 🧱:
- - F-Droid: fix the "-dev" issue in version name (#815)
Changes in RiotX 0.13.0 (2020-01-17) Changes in RiotX 0.13.0 (2020-01-17)
=================================================== ===================================================

View file

@ -27,7 +27,7 @@ static def generateVersionCodeFromTimestamp() {
// It's unix timestamp, minus timestamp of October 3rd 2018 (first commit date) divided by 100: It's incremented by one every 100 seconds. // It's unix timestamp, minus timestamp of October 3rd 2018 (first commit date) divided by 100: It's incremented by one every 100 seconds.
// plus 20_000_000 for compatibility reason with the previous way the Version Code was computed // plus 20_000_000 for compatibility reason with the previous way the Version Code was computed
// Note that the result will be multiplied by 10 when adding the digit for the arch // Note that the result will be multiplied by 10 when adding the digit for the arch
return ((getGitTimestamp() - 1_538_524_800 ) / 100).toInteger() + 20_000_000 return ((getGitTimestamp() - 1_538_524_800) / 100).toInteger() + 20_000_000
} }
def generateVersionCodeFromVersionName() { def generateVersionCodeFromVersionName() {
@ -66,7 +66,8 @@ static def gitBranchName() {
} }
} }
static def getVersionSuffix() { // For Google Play build, build on any other branch than master will have a "-dev" suffix
static def getGplayVersionSuffix() {
if (gitBranchName() == "master") { if (gitBranchName() == "master") {
return "" return ""
} else { } else {
@ -74,6 +75,20 @@ static def getVersionSuffix() {
} }
} }
static def gitTag() {
def cmd = "git describe --exact-match --tags"
return cmd.execute().text.trim()
}
// For F-Droid build, build on a not tagged commit will have a "-dev" suffix
static def getFdroidVersionSuffix() {
if (gitTag() == "") {
return "-dev"
} else {
return ""
}
}
project.android.buildTypes.all { buildType -> project.android.buildTypes.all { buildType ->
buildType.javaCompileOptions.annotationProcessorOptions.arguments = buildType.javaCompileOptions.annotationProcessorOptions.arguments =
[ [
@ -102,8 +117,6 @@ android {
// Other branches (master, features, etc.) will have version code based on application version. // Other branches (master, features, etc.) will have version code based on application version.
versionCode project.getVersionCode() versionCode project.getVersionCode()
versionName "${versionMajor}.${versionMinor}.${versionPatch}${getVersionSuffix()}"
buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\"" buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\""
resValue "string", "git_revision", "\"${gitRevision()}\"" resValue "string", "git_revision", "\"${gitRevision()}\""
@ -190,6 +203,8 @@ android {
gplay { gplay {
dimension "store" dimension "store"
versionName "${versionMajor}.${versionMinor}.${versionPatch}${getGplayVersionSuffix()}"
resValue "bool", "isGplay", "true" resValue "bool", "isGplay", "true"
buildConfigField "boolean", "ALLOW_FCM_USE", "true" buildConfigField "boolean", "ALLOW_FCM_USE", "true"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
@ -199,6 +214,8 @@ android {
fdroid { fdroid {
dimension "store" dimension "store"
versionName "${versionMajor}.${versionMinor}.${versionPatch}${getFdroidVersionSuffix()}"
resValue "bool", "isGplay", "false" resValue "bool", "isGplay", "false"
buildConfigField "boolean", "ALLOW_FCM_USE", "false" buildConfigField "boolean", "ALLOW_FCM_USE", "false"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""