diff --git a/app/build.gradle b/app/build.gradle index 1511c3ecd..0ba070c43 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,3 +1,4 @@ +apply from: '../gitutils.gradle' apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-kapt' @@ -78,6 +79,7 @@ android { applicationId 'fr.free.nrw.commons' versionCode 74 versionName '2.5.0' + setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName()) minSdkVersion project.minSdkVersion targetSdkVersion project.targetSdkVersion testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -95,6 +97,7 @@ android { } debug { testCoverageEnabled true + versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion() } } diff --git a/gitutils.gradle b/gitutils.gradle new file mode 100644 index 000000000..e84cb1eda --- /dev/null +++ b/gitutils.gradle @@ -0,0 +1,21 @@ +ext.getBuildVersion = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() +} + +ext.getBranchName = { -> + try { + def stdOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' + standardOutput = stdOut + } + return stdOut.toString().trim() + } catch (ignored) { + return null + } +}