diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts index eef0c06..56d6d08 100644 --- a/mobile/build.gradle.kts +++ b/mobile/build.gradle.kts @@ -4,6 +4,16 @@ plugins { alias(libs.plugins.kotlin.serialization) } +fun generateVersionCode(): Int { + return try { + val process = ProcessBuilder("git", "rev-list", "--count", "HEAD").start() + + "${process.inputStream.bufferedReader().readText().trim()}0".toInt() // 0 at end for mobile + } catch (e: Exception) { + 1 + } +} + android { namespace = "ru.omni_devel.cards" compileSdk = 36 @@ -12,7 +22,7 @@ android { applicationId = "ru.omni_devel.cards" minSdk = 30 targetSdk = 36 - versionCode = 80 // 0 at end for mobile + versionCode = generateVersionCode() versionName = "2.3.1" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/wear/build.gradle.kts b/wear/build.gradle.kts index aae3fe0..5a3f467 100644 --- a/wear/build.gradle.kts +++ b/wear/build.gradle.kts @@ -4,6 +4,16 @@ plugins { alias(libs.plugins.kotlin.serialization) } +fun generateVersionCode(): Int { + return try { + val process = ProcessBuilder("git", "rev-list", "--count", "HEAD").start() + + "${process.inputStream.bufferedReader().readText().trim()}1".toInt() // 0 at end for WearOS + } catch (e: Exception) { + 1 + } +} + android { namespace = "ru.omni_devel.cards" compileSdk = 36 @@ -12,7 +22,7 @@ android { applicationId = "ru.omni_devel.cards" minSdk = 30 targetSdk = 36 - versionCode = 71 // 1 at end for WearOS + versionCode = generateVersionCode() versionName = "1.3.0" }