Commit d5cb4388 authored by Drahomír Karchňák's avatar Drahomír Karchňák

Gradle now renames apks after build.

parent 2534e277
......@@ -16,9 +16,10 @@ out/
build/
.gradle/
gradle.properties
local.properties
## OS Specific
.DS_Store
## General
*.zip
*.zip
\ No newline at end of file
......@@ -55,18 +55,18 @@ AndroidAppDev:
AndroidAppDebug:
stage: AndroidApp
only:
- tags
allow_failure: true
script:
- >
if git diff $LAST_PIPELINE_COMMIT HEAD --name-only|grep RMBTAndroid; then
echo "Starting Android App build!" &&
cd RMBTAndroid/ && ./gradlew clean assembleDebug test lint && cd ..
fi;
artifacts:
paths:
- RMBTAndroid/build/outputs/apk/debug/*.apk
only:
- tags
allow_failure: true
script:
- >
if git diff $LAST_PIPELINE_COMMIT HEAD --name-only|grep RMBTAndroid; then
echo "Starting Android App build!" &&
cd RMBTAndroid/ && ./gradlew clean assembleDebug test lint && cd ..
fi;
artifacts:
paths:
- RMBTAndroid/build/outputs/apk/debug/*.apk
AndroidAppRelease:
stage: AndroidApp
......
......@@ -113,7 +113,7 @@ android {
defaultConfig {
targetSdkVersion 19
versionName getVersionNameFromGit()
versionName getVersionNameFromGit(false)
versionCode getVersionCodeFromGit()
applicationId = 'cz.nic.netmetr'
......@@ -178,6 +178,15 @@ android {
}
}
applicationVariants.all { variant ->
def extraInfo = variant.name.equals("dev")
variant.outputs.all {output ->
def file = output.outputFile;
outputFileName = file.name.replace(".apk", "-" + getVersionNameFromGit(extraInfo) + ".apk")
}
}
lintOptions {
abortOnError false
}
......@@ -239,15 +248,31 @@ def initResValues(buildType, IPv4Host, IPv6Host, IPv4CheckHost, IPv6CheckHost, C
}
}
def getVersionNameFromGit() {
def stdoutVersion = new ByteArrayOutputStream()
def getVersionNameFromGit(extraInfo) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--always'
standardOutput = stdoutVersion
commandLine 'git', 'describe', '--abbrev=0', '--tags', '--always'
standardOutput = stdout
}
def tagVersion = stdout.toString().trim()
//add branch name and commit count from last tag
if(extraInfo) {
def branchName = getBranchNameFromGit()
//Get commit count
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', "${tagVersion}..HEAD", '--count'
standardOutput = stdout
}
def commitCount = stdout.toString().trim()
return "${tagVersion}-${branchName}(${commitCount})"
}
def branchName = getBranchNameFromGit()
return stdoutVersion.toString().trim() + '-' + branchName
return tagVersion
}
def getBranchNameFromGit() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment