CI/Travis: Fix tagged builds

This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis 2018-09-12 13:43:26 +03:00
parent 00ecf2f1ce
commit 1a09ccb587
1 changed files with 12 additions and 5 deletions

View File

@ -1,11 +1,20 @@
apply plugin: 'com.android.application' apply plugin: 'com.android.application'
apply plugin: 'com.github.triplet.play' apply plugin: 'com.github.triplet.play'
def getVersionCode = { -> def getBuildId = { ->
def build_id = System.getenv("TRAVIS_JOB_ID") ?: "8" def build_id = System.getenv("TRAVIS_JOB_ID") ?: "8"
return Integer.parseInt( build_id ) 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 getVersionName = { ->
def stdout = new ByteArrayOutputStream() def stdout = new ByteArrayOutputStream()
exec { exec {
@ -23,7 +32,7 @@ android {
applicationId "com.reicast.emulator" applicationId "com.reicast.emulator"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 25 targetSdkVersion 25
versionCode getVersionCode() versionCode getBuildId()
versionName getVersionName() versionName getVersionName()
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true
@ -72,9 +81,7 @@ android {
afterEvaluate { afterEvaluate {
android.applicationVariants.all { v -> android.applicationVariants.all { v ->
if (v.buildType.name == "release") { if (v.buildType.name == "release") {
def hashtag = getVersionName() def hashtag = getVersionHash()
def start = hashtag.lastIndexOf("-")
hashtag = hashtag.substring(start + 2, start + 9)
v.outputs[0].outputFileName = "reicast-android-" + hashtag + ".apk" v.outputs[0].outputFileName = "reicast-android-" + hashtag + ".apk"
} }
} }