From 1b6bc7a18f614bc9e1aad6a234d5ad4a399be56e Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sat, 11 Dec 2021 20:29:42 +0100 Subject: version: automatically generate version string from tag Signed-off-by: Mikael Magnusson --- ui/build.gradle.kts | 6 +++++- ui/src/main/java/com/wireguard/android/updater/Updater.kt | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'ui') diff --git a/ui/build.gradle.kts b/ui/build.gradle.kts index d5ce5997..8375e726 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 = 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 fabfae92..6781a60d 100644 --- a/ui/src/main/java/com/wireguard/android/updater/Updater.kt +++ b/ui/src/main/java/com/wireguard/android/updater/Updater.kt @@ -146,7 +146,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() } } @@ -412,4 +415,4 @@ object Updater { context.startActivity(start) } } -} \ No newline at end of file +} -- cgit v1.2.3