Merge pull request #474 from vector-im/feature/dev_suffix

Automatic "-dev" version suffix on non master branch
This commit is contained in:
Benoit Marty 2019-08-14 18:15:44 +02:00 committed by GitHub
commit 6cc0c0672e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 7 deletions

View File

@ -29,7 +29,15 @@ static def generateVersionCodeFromTimestamp() {
} }


def generateVersionCodeFromVersionName() { def generateVersionCodeFromVersionName() {
return versionMajor * 10000 + versionMinor * 100 + versionPatch return versionMajor * 1_00_00 + versionMinor * 1_00 + versionPatch
}

def getVersionCode() {
if (gitBranchName() == "develop") {
return generateVersionCodeFromTimestamp()
} else {
return generateVersionCodeFromVersionName()
}
} }


static def gitRevision() { static def gitRevision() {
@ -47,6 +55,14 @@ static def gitBranchName() {
return cmd.execute().text.trim() return cmd.execute().text.trim()
} }


static def getVersionSuffix() {
if (gitBranchName() == "master") {
return ""
} else {
return "-dev"
}
}

project.android.buildTypes.all { buildType -> project.android.buildTypes.all { buildType ->
buildType.javaCompileOptions.annotationProcessorOptions.arguments = buildType.javaCompileOptions.annotationProcessorOptions.arguments =
[ [
@ -71,9 +87,11 @@ android {
targetSdkVersion 28 targetSdkVersion 28
multiDexEnabled true multiDexEnabled true


// Note: versionCode is depending on the build variant // `develop` branch will have version code from timestamp, to ensure each build from CI has a incremented versionCode.
// Other branches (master, features, etc.) will have version code based on application version.
versionCode project.getVersionCode()


versionName "${versionMajor}.${versionMinor}.${versionPatch}-dev" 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()}\""
@ -161,8 +179,6 @@ android {
gplay { gplay {
dimension "store" dimension "store"


versionCode = generateVersionCodeFromVersionName()

buildConfigField "boolean", "ALLOW_FCM_USE", "true" buildConfigField "boolean", "ALLOW_FCM_USE", "true"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
@ -171,8 +187,6 @@ android {
fdroid { fdroid {
dimension "store" dimension "store"


versionCode = generateVersionCodeFromTimestamp()

buildConfigField "boolean", "ALLOW_FCM_USE", "false" buildConfigField "boolean", "ALLOW_FCM_USE", "false"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\"" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""