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.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"
}
}