From 3f792c7a840da45365b7b176a794f9deb019a1b7 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 8 Aug 2019 16:57:03 +0200 Subject: [PATCH 1/2] Automatic "-dev" version suffix on non master branch --- vector/build.gradle | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vector/build.gradle b/vector/build.gradle index 60a4542d..8393462c 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -47,6 +47,14 @@ static def gitBranchName() { return cmd.execute().text.trim() } +static def getVersionSuffix() { + if (gitBranchName() == "master") { + return "" + } else { + return "-dev" + } +} + project.android.buildTypes.all { buildType -> buildType.javaCompileOptions.annotationProcessorOptions.arguments = [ @@ -73,7 +81,7 @@ android { // Note: versionCode is depending on the build variant - versionName "${versionMajor}.${versionMinor}.${versionPatch}-dev" + versionName "${versionMajor}.${versionMinor}.${versionPatch}${getVersionSuffix()}" buildConfigField "String", "GIT_REVISION", "\"${gitRevision()}\"" resValue "string", "git_revision", "\"${gitRevision()}\"" From 4ca2531e47b66575343d910bee31431e588b0667 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 14 Aug 2019 10:43:47 +0200 Subject: [PATCH 2/2] `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. --- vector/build.gradle | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/vector/build.gradle b/vector/build.gradle index 8393462c..2e5c1adc 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -29,7 +29,15 @@ static def generateVersionCodeFromTimestamp() { } 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() { @@ -79,7 +87,9 @@ android { targetSdkVersion 28 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}${getVersionSuffix()}" @@ -169,8 +179,6 @@ android { gplay { dimension "store" - versionCode = generateVersionCodeFromVersionName() - buildConfigField "boolean", "ALLOW_FCM_USE", "true" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\"" @@ -179,8 +187,6 @@ android { fdroid { dimension "store" - versionCode = generateVersionCodeFromTimestamp() - buildConfigField "boolean", "ALLOW_FCM_USE", "false" buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\"" buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""