summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2021-12-11 20:29:42 +0100
committerMikael Magnusson <mikma@users.sourceforge.net>2023-10-25 23:03:39 +0200
commite7a73f171050746efe0798a98e5499028a707c0b (patch)
tree2de79ff15b6ba2fb3100748cbeafaec18e584a22
parent0a8de709b6ee34af39a96d62ec825d0daadd964d (diff)
version: automatically generate version string from tagversion
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
-rw-r--r--gradle/libs.versions.toml2
-rw-r--r--ui/build.gradle.kts6
-rw-r--r--ui/src/main/java/com/wireguard/android/updater/Updater.kt5
3 files changed, 11 insertions, 2 deletions
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index d8527046..442707ae 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,5 +1,6 @@
[versions]
agp = "8.2.0-beta06"
+grgit = "5.2.0"
kotlin = "1.9.0"
[libraries]
@@ -23,6 +24,7 @@ kotlinx-coroutines-android = "org.jetbrains.kotlinx:kotlinx-coroutines-android:1
zxing-android-embedded = "com.journeyapps:zxing-android-embedded:4.3.0"
[plugins]
+ajoberstar-grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" }
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts
index 5cdcb6a1..be11cc30 100644
--- a/ui/build.gradle.kts
+++ b/ui/build.gradle.kts
@@ -9,6 +9,7 @@ plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.kapt)
+ alias(libs.plugins.ajoberstar.grgit)
}
android {
@@ -24,7 +25,10 @@ android {
minSdk = 21
targetSdk = 34
versionCode = providers.gradleProperty("wireguardVersionCode").get().toInt()
- versionName = providers.gradleProperty("wireguardVersionName").get()
+ versionName = grgit.describe {
+ tags = true
+ always = true
+ }.replace('-', '.')
buildConfigField("int", "MIN_SDK_VERSION", minSdk.toString())
}
compileOptions {
diff --git a/ui/src/main/java/com/wireguard/android/updater/Updater.kt b/ui/src/main/java/com/wireguard/android/updater/Updater.kt
index 651e3cd7..87adad96 100644
--- a/ui/src/main/java/com/wireguard/android/updater/Updater.kt
+++ b/ui/src/main/java/com/wireguard/android/updater/Updater.kt
@@ -152,7 +152,10 @@ object Updater {
throw InvalidParameterException("Version has no parts")
parts = ULongArray(strParts.size)
for (i in parts.indices) {
- parts[i] = strParts[i].toULong()
+ if (strParts[i][0] == 'g')
+ parts[i] = strParts[i].substring(1).toULong(16)
+ else
+ parts[i] = strParts[i].toULong()
}
}