Skip to content

Commit 68261c3

Browse files
author
maskara
committed
Use modified branch names for APK
1 parent c926437 commit 68261c3

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
apply from: '../gitutils.gradle'
12
apply plugin: 'com.android.application'
23
apply plugin: 'jacoco-android'
34
apply from: 'quality.gradle'
@@ -66,6 +67,7 @@ android {
6667
applicationId 'fr.free.nrw.commons'
6768
versionCode 74
6869
versionName '2.5.0'
70+
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
6971
minSdkVersion project.minSdkVersion
7072
targetSdkVersion project.targetSdkVersion
7173
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -79,6 +81,7 @@ android {
7981
}
8082
debug {
8183
testCoverageEnabled true
84+
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
8285
}
8386
}
8487

gitutils.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ext.getBuildVersion = { ->
2+
def stdout = new ByteArrayOutputStream()
3+
exec {
4+
commandLine 'git', 'rev-parse', '--short', 'HEAD'
5+
standardOutput = stdout
6+
}
7+
return stdout.toString().trim()
8+
}
9+
10+
ext.getBranchName = { ->
11+
try {
12+
def stdOut = new ByteArrayOutputStream()
13+
exec {
14+
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
15+
standardOutput = stdOut
16+
}
17+
return stdOut.toString().trim()
18+
} catch (ignored) {
19+
return null
20+
}
21+
}

0 commit comments

Comments
 (0)