feat: enhance APK naming and versioning logic

This commit is contained in:
二刺螈 2026-03-28 14:23:51 +08:00
parent 299c6042d4
commit d0562ff6e6
2 changed files with 17 additions and 5 deletions

View File

@ -35,13 +35,15 @@ jobs:
echo GKD_KEY_ALIAS='${{ secrets.GKD_KEY_ALIAS }}' >> gradle.properties
echo GKD_KEY_PASSWORD='${{ secrets.GKD_KEY_PASSWORD }}' >> gradle.properties
- run: echo GKD_RENAME_APK_FLAG=1 >> gradle.properties
- run: chmod 777 ./gradlew
- run: ./gradlew app:assembleGkdRelease
- uses: actions/upload-artifact@v7
with:
archive: false
path: app/build/outputs/apk/gkd/release/app-gkd-release.apk
path: app/build/outputs/apk/gkd/release/*.apk
- uses: actions/upload-artifact@v7
with:

View File

@ -1,3 +1,4 @@
import com.android.build.api.variant.impl.VariantOutputImpl
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import kotlin.reflect.full.declaredMemberProperties
@ -17,7 +18,9 @@ data class GitInfo(
val commitId: String,
val commitTime: String,
val tagName: String?,
)
) {
val versionNameSuffix get() = if (tagName == null) ("-" + commitId.take(7)) else null
}
val gitInfo = GitInfo(
commitId = "git rev-parse HEAD".runCommand(),
@ -112,9 +115,7 @@ android {
buildTypes {
all {
if (gitInfo.tagName == null) {
versionNameSuffix = "-${gitInfo.commitId.take(7)}"
}
versionNameSuffix = gitInfo.versionNameSuffix
}
release {
isMinifyEnabled = true
@ -168,6 +169,15 @@ android {
)
}
if (project.hasProperty("GKD_RENAME_APK_FLAG")) {
androidComponents.onVariants { variant ->
variant.outputs.onEach { output ->
output as VariantOutputImpl
output.outputFileName = "gkd-v${output.versionName.get()}.apk"
}
}
}
kotlin {
compilerOptions {
jvmTarget.set(rootProject.ext["kotlin.jvmTarget"] as JvmTarget)