Skip to content

Commit 7a9ff8c

Browse files
authored
Merge pull request commons-app#977 from maskaravivek/apkName
Use modified branch names for APK
2 parents b91847e + 68261c3 commit 7a9ff8c

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: 'kotlin-android'
34
apply plugin: 'kotlin-kapt'
@@ -78,6 +79,7 @@ android {
7879
applicationId 'fr.free.nrw.commons'
7980
versionCode 74
8081
versionName '2.5.0'
82+
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
8183
minSdkVersion project.minSdkVersion
8284
targetSdkVersion project.targetSdkVersion
8385
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -95,6 +97,7 @@ android {
9597
}
9698
debug {
9799
testCoverageEnabled true
100+
versionNameSuffix "-debug-" + getBranchName() + "~" + getBuildVersion()
98101
}
99102
}
100103

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)