mirror of
https://github.com/EasyTier/EasyTier.git
synced 2026-04-23 00:27:06 +08:00
fix: resolve Android APK version fallback to 1.0 on CI (#2131)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
import groovy.json.JsonSlurper
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
@@ -14,6 +15,35 @@ val tauriProperties = Properties().apply {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val versionPattern = Regex("""^(\d+)\.(\d+)\.(\d+)$""")
|
||||||
|
|
||||||
|
val tauriVersionName = tauriProperties.getProperty("tauri.android.versionName")?.ifBlank { null } ?: run {
|
||||||
|
val tauriConfFile = file("../../../tauri.conf.json")
|
||||||
|
check(tauriConfFile.exists()) { "Missing tauri.conf.json at ${tauriConfFile.path}" }
|
||||||
|
|
||||||
|
val tauriConf = tauriConfFile.reader(Charsets.UTF_8).use { JsonSlurper().parse(it) as? Map<*, *> }
|
||||||
|
?: error("Failed to parse ${tauriConfFile.path} as a JSON object")
|
||||||
|
tauriConf["version"] as? String
|
||||||
|
?: error("Missing string field \"version\" in ${tauriConfFile.path}")
|
||||||
|
}
|
||||||
|
|
||||||
|
val tauriVersionMatch = versionPattern.matchEntire(tauriVersionName)
|
||||||
|
?: error("Android version must use x.y.z format, but got \"$tauriVersionName\"")
|
||||||
|
|
||||||
|
val tauriVersionCode = if (tauriProperties.getProperty("tauri.android.versionName")?.ifBlank { null } != null) {
|
||||||
|
val versionCodeProp = tauriProperties.getProperty("tauri.android.versionCode")
|
||||||
|
if (versionCodeProp != null) {
|
||||||
|
versionCodeProp.toIntOrNull()
|
||||||
|
?: error("Property \"tauri.android.versionCode\" must be an integer, but got \"$versionCodeProp\"")
|
||||||
|
} else {
|
||||||
|
val (major, minor, patch) = tauriVersionMatch.destructured
|
||||||
|
major.toInt() * 1_000_000 + minor.toInt() * 1_000 + patch.toInt()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val (major, minor, patch) = tauriVersionMatch.destructured
|
||||||
|
major.toInt() * 1_000_000 + minor.toInt() * 1_000 + patch.toInt()
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk = 34
|
compileSdk = 34
|
||||||
namespace = "com.kkrainbow.easytier"
|
namespace = "com.kkrainbow.easytier"
|
||||||
@@ -22,8 +52,8 @@ android {
|
|||||||
applicationId = "com.kkrainbow.easytier"
|
applicationId = "com.kkrainbow.easytier"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 34
|
targetSdk = 34
|
||||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
versionCode = tauriVersionCode
|
||||||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
versionName = tauriVersionName
|
||||||
}
|
}
|
||||||
signingConfigs {
|
signingConfigs {
|
||||||
create("release") {
|
create("release") {
|
||||||
|
|||||||
Reference in New Issue
Block a user