ci: build signed apk

Co-authored-by: MinoriceOwO <154642983+minoriceowo@users.noreply.github.com>
This commit is contained in:
BinTianqi
2024-05-25 14:14:12 +08:00
parent f9ff27446e
commit acf3cb6b81
3 changed files with 67 additions and 11 deletions

View File

@@ -3,19 +3,24 @@ plugins {
alias(libs.plugins.kotlin.android)
}
var keyPassword: String? = null
var keystorePassword: String? = null
var keyAlias: String? = null
android {
signingConfigs {
create("testkey") {
storeFile = file("testkey.jks")
storePassword = "testkey"
keyPassword = "testkey"
keyAlias = "testkey"
storeFile = file("signature.jks")
storePassword = keystorePassword ?: "testkey"
keyPassword = keyPassword ?: "testkey"
keyAlias = keyAlias ?: "testkey"
}
}
namespace = "com.bintianqi.owndroid"
compileSdk = 34
lint.checkReleaseBuilds = false
lint.disable += "All"
defaultConfig {
applicationId = "com.bintianqi.owndroid"
@@ -68,6 +73,35 @@ android {
}
}
gradle.taskGraph.whenReady {
project.tasks.findByPath(":app:test")?.enabled = false
project.tasks.findByPath(":app:lint")?.enabled = false
project.tasks.findByPath(":app:lintAnalyzeDebug")?.enabled = false
}
tasks.findByName("preBuild")?.dependsOn?.plusAssign("prepareSignature")
tasks.register("prepareSignature") {
doFirst {
file("signature.jks").let {
if(!it.exists()) file("testkey.jks").copyTo(it)
}
keystorePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEY_PASSWORD")
}
}
tasks.findByName("clean")?.dependsOn?.plusAssign("cleanKey")
tasks.register("cleanKey") {
doFirst {
file("signature.jks").let {
if(it.exists()) it.delete()
}
}
}
dependencies {
implementation(libs.androidx.activity.compose)
implementation(libs.androidx.ui)