mirror of
https://github.com/aljazceru/Android-nRF-Toolbox.git
synced 2026-01-04 15:24:19 +01:00
Add app versioning which base on tags
This commit is contained in:
@@ -5,6 +5,7 @@ plugins {
|
||||
id 'kotlin-kapt'
|
||||
id 'dagger.hilt.android.plugin'
|
||||
}
|
||||
apply from: rootProject.file("gradle/git-tag-version.gradle")
|
||||
|
||||
android {
|
||||
compileSdk android_api_version
|
||||
@@ -13,8 +14,8 @@ android {
|
||||
applicationId "no.nordicsemi.android.nrftoolbox"
|
||||
minSdk android_min_api_version
|
||||
targetSdk android_api_version
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
versionCode getVersionCodeFromTags()
|
||||
versionName getVersionNameFromTags()
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables {
|
||||
|
||||
27
gradle/git-tag-version.gradle
Normal file
27
gradle/git-tag-version.gradle
Normal file
@@ -0,0 +1,27 @@
|
||||
ext.getVersionCodeFromTags = { ->
|
||||
try {
|
||||
def code = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'tag', '--list'
|
||||
standardOutput = code
|
||||
}
|
||||
return 14 + code.toString().split("\n").size()
|
||||
}
|
||||
catch (ignored) {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
ext.getVersionNameFromTags = { ->
|
||||
try {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'describe', '--tags', '--abbrev=0'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim().split("%")[0]
|
||||
}
|
||||
catch (ignored) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user