fix: sign android apk
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
@@ -14,14 +13,19 @@ val tauriProperties = Properties().apply {
|
||||
}
|
||||
}
|
||||
|
||||
// Load signing credentials
|
||||
// Load signing credentials.
|
||||
// Locally: optional (debug builds and `tauri android dev` work without it).
|
||||
// In CI: mandatory, so a broken secrets setup fails loudly instead of
|
||||
// producing an unsigned APK.
|
||||
val keystoreProperties = Properties().apply {
|
||||
val keystoreFile = rootProject.file("keystore.properties")
|
||||
require(keystoreFile.exists()) {
|
||||
"Missing keystore.properties"
|
||||
if (keystoreFile.exists()) {
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
} else if (System.getenv("CI") != null) {
|
||||
error("Missing keystore.properties in CI")
|
||||
}
|
||||
keystoreFile.inputStream().use { load(it) }
|
||||
}
|
||||
val hasKeystore = keystoreProperties.containsKey("storeFile")
|
||||
|
||||
android {
|
||||
compileSdk = 36
|
||||
@@ -39,20 +43,22 @@ android {
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val keystorePath = keystoreProperties.getProperty("storeFile")
|
||||
?: error("Missing storeFile")
|
||||
if (hasKeystore) {
|
||||
create("release") {
|
||||
val keystorePath = keystoreProperties.getProperty("storeFile")
|
||||
?: error("Missing storeFile")
|
||||
|
||||
storeFile = rootProject.file(keystorePath)
|
||||
storeFile = rootProject.file(keystorePath)
|
||||
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
?: error("Missing storePassword")
|
||||
storePassword = keystoreProperties.getProperty("storePassword")
|
||||
?: error("Missing storePassword")
|
||||
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
?: error("Missing keyAlias")
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
?: error("Missing keyAlias")
|
||||
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
?: error("Missing keyPassword")
|
||||
keyPassword = keystoreProperties.getProperty("keyPassword")
|
||||
?: error("Missing keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +79,9 @@ android {
|
||||
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
if (hasKeystore) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
|
||||
proguardFiles(
|
||||
*fileTree(".") { include("**/*.pro") }
|
||||
@@ -109,4 +117,4 @@ dependencies {
|
||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||
}
|
||||
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
apply(from = "tauri.build.gradle.kts")
|
||||
Reference in New Issue
Block a user