calculate android build numbers from version

This commit is contained in:
Henry Hiles 2026-11-12 00:26:23 -05:00
commit dab84063e2
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -14,6 +14,13 @@ if (keystorePropertiesFile.exists()) {
}
}
fun versionCodeOf(versionName: String): Int {
val parts = versionName.split("-", limit = 2)
val (major, minor, patch) = parts[0].split(".").map(String::toInt)
val preRelease = parts.getOrNull(1)?.let { Regex("\\d+").find(it)?.value?.toInt() ?: 0 } ?: 999
return major * 100_000_000 + minor * 1_000_000 + patch * 10_000 + preRelease
}
android {
namespace = "nexus.federated.nexus"
compileSdk = 36
@ -31,7 +38,7 @@ android {
minSdk = 29
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionCode = versionCodeOf(flutter.versionName!!)
versionName = flutter.versionName
multiDexEnabled = true