diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2021-12-11 20:29:42 +0100 |
---|---|---|
committer | Mikael Magnusson <mikma@users.sourceforge.net> | 2023-05-27 21:54:33 +0200 |
commit | c559755ff6a434ca76571f5577f123ba4aadf52b (patch) | |
tree | 16c30116e60cdfbf62bd6fa204e18cf39f6a4706 | |
parent | e9243c403ad7c80c87c632e3e4f0cf70ff959b18 (diff) |
version: automatically generate version string from tag
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
-rw-r--r-- | gradle/libs.versions.toml | 2 | ||||
-rw-r--r-- | ui/build.gradle.kts | 6 | ||||
-rw-r--r-- | ui/src/main/java/com/wireguard/android/updater/Updater.kt | 5 |
3 files changed, 11 insertions, 2 deletions
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index d574e601..982a7ae5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,6 @@ [versions] agp = "8.2.0-alpha05" +grgit = "5.2.0" kotlin = "1.8.21" [libraries] @@ -25,5 +26,6 @@ zxing-android-embedded = "com.journeyapps:zxing-android-embedded:4.3.0" [plugins] android-application = { id = "com.android.application", version.ref = "agp" } android-library = { id = "com.android.library", version.ref = "agp" } +ajoberstar-grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" } diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts index 3672c1ee..34a32d5b 100644 --- a/ui/build.gradle.kts +++ b/ui/build.gradle.kts @@ -10,6 +10,7 @@ plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.kapt) + alias(libs.plugins.ajoberstar.grgit) } android { @@ -25,7 +26,10 @@ android { minSdk = 21 targetSdk = 33 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 dbdbacfe..adcb3836 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() } } |