From 1a09ccb5871a75f41fd49ee1434bbb9bc499d0bd Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Wed, 12 Sep 2018 13:43:26 +0300 Subject: [PATCH] CI/Travis: Fix tagged builds --- shell/android-studio/reicast/build.gradle | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/shell/android-studio/reicast/build.gradle b/shell/android-studio/reicast/build.gradle index 127861bb1..b51029928 100644 --- a/shell/android-studio/reicast/build.gradle +++ b/shell/android-studio/reicast/build.gradle @@ -1,11 +1,20 @@ apply plugin: 'com.android.application' apply plugin: 'com.github.triplet.play' -def getVersionCode = { -> +def getBuildId = { -> def build_id = System.getenv("TRAVIS_JOB_ID") ?: "8" return Integer.parseInt( build_id ) } +def getVersionHash = { -> + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() +} + def getVersionName = { -> def stdout = new ByteArrayOutputStream() exec { @@ -23,7 +32,7 @@ android { applicationId "com.reicast.emulator" minSdkVersion 16 targetSdkVersion 25 - versionCode getVersionCode() + versionCode getBuildId() versionName getVersionName() vectorDrawables.useSupportLibrary = true @@ -72,9 +81,7 @@ android { afterEvaluate { android.applicationVariants.all { v -> if (v.buildType.name == "release") { - def hashtag = getVersionName() - def start = hashtag.lastIndexOf("-") - hashtag = hashtag.substring(start + 2, start + 9) + def hashtag = getVersionHash() v.outputs[0].outputFileName = "reicast-android-" + hashtag + ".apk" } }