mirror of
https://github.com/gkd-kit/gkd.git
synced 2026-06-03 21:01:49 +08:00
feat: enhance APK naming and versioning logic
This commit is contained in:
parent
299c6042d4
commit
d0562ff6e6
4
.github/workflows/Build-Apk.yml
vendored
4
.github/workflows/Build-Apk.yml
vendored
@ -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:
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user