set versionName based on git release tag

This makes it easy to tell which debug build a device is running, since the
versionName now automatically describes the exact commit that was built,
based on `git describe`, e.g.:  0.100-alpha7-33-gc2e8e8a

For release builds, i.e. builds from commits that are tagged as releases,
the versionName will be just the tag name: 0.100-alpha8

closes #664 https://gitlab.com/fdroid/fdroidclient/issues/664
This commit is contained in:
Hans-Christoph Steiner 2016-05-19 08:27:50 +02:00
parent 7fbce1f09c
commit f7c043b3fc
2 changed files with 12 additions and 3 deletions

View File

@ -3,6 +3,16 @@ apply plugin: 'witness'
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
apply plugin: 'pmd' apply plugin: 'pmd'
/* gets the version name from the latest Git tag, stripping the leading v off */
def getVersionName = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdout
}
return stdout.toString().trim().substring(1)
}
repositories { repositories {
jcenter() jcenter()
} }
@ -150,6 +160,7 @@ android {
} }
defaultConfig { defaultConfig {
versionName getVersionName()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }

View File

@ -2,9 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.fdroid.fdroid" package="org.fdroid.fdroid"
android:installLocation="auto" android:installLocation="auto"
android:versionCode="100007" android:versionCode="100007">
android:versionName="0.100-alpha7"
>
<uses-sdk <uses-sdk
android:minSdkVersion="8" android:minSdkVersion="8"