改为语义化版本号
This commit is contained in:
+25
-7
@@ -15,14 +15,31 @@ plugins {
|
|||||||
}
|
}
|
||||||
apply from: 'download.gradle'
|
apply from: 'download.gradle'
|
||||||
|
|
||||||
static def releaseTime() {
|
ext {
|
||||||
return new Date().format("yy.MMddHH", TimeZone.getTimeZone("GMT+8"))
|
versionMajor = 3
|
||||||
|
versionMinor = 25
|
||||||
|
versionPatch = 9
|
||||||
}
|
}
|
||||||
|
|
||||||
def name = "legado"
|
def name = "legado"
|
||||||
def version = "3." + releaseTime()
|
|
||||||
def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
|
def gitCommits = Integer.parseInt('git rev-list HEAD --count'.execute().text.trim())
|
||||||
|
|
||||||
|
ext.versionBuild = gitCommits
|
||||||
|
ext.versionName = "${ext.versionMajor}.${ext.versionMinor}.${ext.versionPatch}"
|
||||||
|
|
||||||
|
def getGitCommitHash() {
|
||||||
|
try {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return stdout.toString().trim()
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
return "unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdk = compile_sdk_version
|
compileSdk = compile_sdk_version
|
||||||
namespace 'io.legato.kazusa'
|
namespace 'io.legato.kazusa'
|
||||||
@@ -52,9 +69,9 @@ android {
|
|||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 36
|
targetSdk 36
|
||||||
versionCode 10000 + gitCommits
|
versionCode 10000 + gitCommits
|
||||||
versionName version
|
versionName project.ext.versionName
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
project.ext.set("archivesBaseName", name + "_" + version)
|
project.ext.set("archivesBaseName", name + "_" + versionName)
|
||||||
|
|
||||||
buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
|
buildConfigField "String", "Cronet_Version", "\"$CronetVersion\""
|
||||||
buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
|
buildConfigField "String", "Cronet_Main_Version", "\"$CronetMainVersion\""
|
||||||
@@ -98,7 +115,7 @@ android {
|
|||||||
manifestPlaceholders.put("app_name", "@string/app_name")
|
manifestPlaceholders.put("app_name", "@string/app_name")
|
||||||
|
|
||||||
//applicationIdSuffix '.debug'
|
//applicationIdSuffix '.debug'
|
||||||
versionNameSuffix 'debug'
|
versionNameSuffix "_debug-${getGitCommitHash()}"
|
||||||
minifyEnabled false
|
minifyEnabled false
|
||||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro', 'cronet-proguard-rules.pro'
|
||||||
}
|
}
|
||||||
@@ -127,7 +144,8 @@ android {
|
|||||||
variant.outputs.configureEach { output ->
|
variant.outputs.configureEach { output ->
|
||||||
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
def abi = output.getFilter(com.android.build.OutputFile.ABI)
|
||||||
def flavor = variant.productFlavors[0].name
|
def flavor = variant.productFlavors[0].name
|
||||||
def apkName = "${name}_${flavor}_${defaultConfig.versionName}"
|
def baseVersionName = variant.versionName
|
||||||
|
def apkName = "${name}_${flavor}_${baseVersionName}"
|
||||||
if (abi != null) {
|
if (abi != null) {
|
||||||
apkName += "_${abi}"
|
apkName += "_${abi}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,14 +80,34 @@ object AppUpdateGitHub : AppUpdate.AppUpdateInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun String.versionCompare(other: String): Int {
|
fun String.versionCompare(other: String): Int {
|
||||||
val thisParts = this.split(".")
|
val regex = Regex("""(\d+)|(\D+)""")
|
||||||
val otherParts = other.split(".")
|
val thisParts = regex.findAll(this).map { it.value }.toList()
|
||||||
|
val otherParts = regex.findAll(other).map { it.value }.toList()
|
||||||
val maxLength = maxOf(thisParts.size, otherParts.size)
|
val maxLength = maxOf(thisParts.size, otherParts.size)
|
||||||
|
|
||||||
for (i in 0 until maxLength) {
|
for (i in 0 until maxLength) {
|
||||||
val thisPart = thisParts.getOrNull(i)?.toIntOrNull() ?: 0
|
val a = thisParts.getOrNull(i)
|
||||||
val otherPart = otherParts.getOrNull(i)?.toIntOrNull() ?: 0
|
val b = otherParts.getOrNull(i)
|
||||||
if (thisPart != otherPart) return thisPart - otherPart
|
|
||||||
|
if (a == null) return -1
|
||||||
|
if (b == null) return 1
|
||||||
|
|
||||||
|
val isANum = a.all { it.isDigit() }
|
||||||
|
val isBNum = b.all { it.isDigit() }
|
||||||
|
|
||||||
|
if (isANum && a.length > 1 && a.startsWith("0")) return -1
|
||||||
|
if (isBNum && b.length > 1 && b.startsWith("0")) return 1
|
||||||
|
|
||||||
|
val cmp = if (isANum && isBNum) {
|
||||||
|
a.toInt() - b.toInt()
|
||||||
|
} else {
|
||||||
|
a.compareTo(b)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmp != 0) return cmp
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user