From f7c043b3fc850f3d825d151f42722cdaee105360 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Thu, 19 May 2016 08:27:50 +0200 Subject: [PATCH] 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 --- app/build.gradle | 11 +++++++++++ app/src/main/AndroidManifest.xml | 4 +--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 303045455..d668052a5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,6 +3,16 @@ apply plugin: 'witness' apply plugin: 'checkstyle' 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 { jcenter() } @@ -150,6 +160,7 @@ android { } defaultConfig { + versionName getVersionName() testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4551f1095..7978e0807 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -2,9 +2,7 @@ + android:versionCode="100007">