Use automatic versioning codes

This commit is contained in:
Aleksandras Kostarevas 2024-03-22 15:55:59 -05:00
parent 1a7ae99f0b
commit 94195b31ba
2 changed files with 40 additions and 6 deletions

View File

@ -13,12 +13,15 @@ build:
tags:
- docker
script:
- export VERSION_NAME=`git describe --tags --dirty`
- export VERSION_CODE=`git rev-list --first-parent --count master`
- ./setUpPropertiesCI.sh
- gradle assembleRelease -s
- mv build/outputs/apk/release/latinime-release.apk ./LatinIME-release-$CI_COMMIT_SHORT_SHA.apk
- ./sendZulipMessage.sh "Alpha Keyboard Build - https://gitlab.futo.org/alex/latinime/-/jobs/$CI_JOB_ID/artifacts/raw/LatinIME-release-$CI_COMMIT_SHORT_SHA.apk"
- mv build/outputs/apk/release/latinime-release.apk ./keyboard-$VERSION_NAME.apk
- echo "Keyboard $VERSION_NAME - https://gitlab.futo.org/alex/latinime/-/jobs/$CI_JOB_ID/artifacts/raw/keyboard-$VERSION_NAME.apk"
- echo $VERSION_CODE $VERSION_NAME
artifacts:
name: "LatinIME-release-$CI_COMMIT_SHORT_SHA"
paths:
name: "keyboard-$VERSION_NAME"
paths:
- ./*.apk
when: manual

View File

@ -5,6 +5,34 @@ plugins {
id 'com.android.library' version '8.2.0' apply false
}
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--first-parent', '--count', 'master'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
} catch (ignored) {
project.logger.lifecycle("Failed to get rev-list count from git!")
return -1;
}
}
def getVersionName = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--dirty'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
project.logger.lifecycle("Failed to get version name tag from git!")
return "0.0.0";
}
}
android {
namespace 'org.futo.inputmethod.latin'
@ -22,8 +50,8 @@ android {
defaultConfig {
minSdk 24
targetSdk 34
versionName "0.1.12"
versionCode 43
versionName getVersionName()
versionCode getVersionCode()
applicationId 'org.futo.inputmethod.latin'
testApplicationId 'org.futo.inputmethod.latin.tests'
@ -189,3 +217,6 @@ dependencies {
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.annotation:annotation:1.0.0'
}
project.logger.lifecycle("versionCode = ${android.defaultConfig.versionCode}")
project.logger.lifecycle("versionName = ${android.defaultConfig.versionName}")