feat: 适配 CI 构建
This commit is contained in:
parent
6218f63807
commit
e729125111
1 changed files with 32 additions and 3 deletions
|
|
@ -10,21 +10,43 @@ ksp {
|
||||||
arg("room.schemaLocation", "$projectDir/schemas")
|
arg("room.schemaLocation", "$projectDir/schemas")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 配置版本信息
|
||||||
|
val baseVersionName = "compose-refactor"
|
||||||
|
val commitHash by lazy { "git rev-parse --short HEAD".exec() }
|
||||||
|
val verCode by lazy { "git rev-list --count HEAD".exec().toInt() }
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "cn.super12138.todo"
|
namespace = "cn.super12138.todo"
|
||||||
compileSdk = 35
|
compileSdk = 35
|
||||||
|
|
||||||
|
// 获取 Release 签名
|
||||||
|
val releaseSigning = if (project.hasProperty("releaseStoreFile")) {
|
||||||
|
signingConfigs.create("release") {
|
||||||
|
storeFile = File(project.properties["releaseStoreFile"] as String)
|
||||||
|
storePassword = project.properties["releaseStorePassword"] as String
|
||||||
|
keyAlias = project.properties["releaseKeyAlias"] as String
|
||||||
|
keyPassword = project.properties["releaseKeyPassword"] as String
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
signingConfigs.getByName("debug")
|
||||||
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId = "cn.super12138.todo"
|
applicationId = "cn.super12138.todo"
|
||||||
minSdk = 24
|
minSdk = 24
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 1
|
versionCode = verCode
|
||||||
versionName = "1.0"
|
versionName = "${baseVersionName}-${commitHash}"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
|
base.archivesName.set("todo-${baseVersionName}")
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
all {
|
||||||
|
signingConfig = releaseSigning
|
||||||
|
}
|
||||||
release {
|
release {
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
isShrinkResources = true
|
isShrinkResources = true
|
||||||
|
|
@ -97,3 +119,10 @@ dependencies {
|
||||||
debugImplementation(libs.androidx.ui.tooling)
|
debugImplementation(libs.androidx.ui.tooling)
|
||||||
debugImplementation(libs.androidx.ui.test.manifest)
|
debugImplementation(libs.androidx.ui.test.manifest)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 命令执行工具类
|
||||||
|
fun String.exec(): String = exec(this)
|
||||||
|
|
||||||
|
fun Project.exec(command: String): String = providers.exec {
|
||||||
|
commandLine(command.split(" "))
|
||||||
|
}.standardOutput.asText.get().trim()
|
||||||
Loading…
Reference in a new issue