feat(android): auto-publish signed APK and AAR from CI
Some checks failed
ci / test (pull_request) Failing after 3m13s
Some checks failed
ci / test (pull_request) Failing after 3m13s
Push to main that touches android/** builds a release APK + SDK AAR on docker-amd64, verifies size/ABI/signature, and create-or-joins the Forgejo release. Version is latest v*.*.* patch+1, or v0.1.0 when there are no tags. Release signing uses repo secrets (ANDROID_KEYSTORE_*), not the debug key.
This commit is contained in:
parent
33beeded92
commit
1c4aaefb01
4 changed files with 413 additions and 26 deletions
|
|
@ -6,6 +6,9 @@ plugins {
|
|||
alias(libs.plugins.kotlin.compose)
|
||||
}
|
||||
|
||||
fun envOrNull(name: String): String? =
|
||||
System.getenv(name)?.takeIf { it.isNotBlank() }
|
||||
|
||||
android {
|
||||
namespace = "com.siriusdevops.onionwire"
|
||||
compileSdk = 36
|
||||
|
|
@ -21,13 +24,30 @@ android {
|
|||
applicationId = "com.siriusdevops.onionwire"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 1
|
||||
versionName = "0.1.0"
|
||||
// CI/local release scripts override both via -P. Committed values are
|
||||
// the offline default and match the first automated tag (v0.1.0 → 100).
|
||||
versionCode = (findProperty("onionwire.versionCode") as String?)?.toIntOrNull() ?: 100
|
||||
versionName = (findProperty("onionwire.versionName") as String?) ?: "0.1.0"
|
||||
ndk {
|
||||
abiFilters += onionwireAbis
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
val ksPath = envOrNull("ANDROID_KEYSTORE_FILE")
|
||||
if (ksPath != null) {
|
||||
storeFile = file(ksPath)
|
||||
storePassword = envOrNull("ANDROID_KEYSTORE_PASSWORD")
|
||||
?: error("ANDROID_KEYSTORE_PASSWORD is required when ANDROID_KEYSTORE_FILE is set")
|
||||
keyAlias = envOrNull("ANDROID_KEY_ALIAS")
|
||||
?: error("ANDROID_KEY_ALIAS is required when ANDROID_KEYSTORE_FILE is set")
|
||||
keyPassword = envOrNull("ANDROID_KEY_PASSWORD")
|
||||
?: error("ANDROID_KEY_PASSWORD is required when ANDROID_KEYSTORE_FILE is set")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
// Sideload / device-test builds. Signed with the standard debug key.
|
||||
|
|
@ -43,9 +63,28 @@ android {
|
|||
// :sdk/consumer-rules.pro.
|
||||
isMinifyEnabled = false
|
||||
isShrinkResources = false
|
||||
// Signed with the debug keystore so the release APK installs.
|
||||
// This is NOT a Play upload key — see android/README.md.
|
||||
signingConfig = signingConfigs.getByName("debug")
|
||||
// Repo-owned release keystore via ANDROID_KEYSTORE_* env (Forgejo
|
||||
// secrets in CI, ~/.android/onionwire-release.env locally). CI sets
|
||||
// ONIONWIRE_REQUIRE_RELEASE_KEY=true and fails closed if missing —
|
||||
// the debug keystore is per-machine and would break in-place upgrades.
|
||||
val requireReleaseKey =
|
||||
(findProperty("onionwire.requireReleaseKey") as String?) == "true" ||
|
||||
envOrNull("ONIONWIRE_REQUIRE_RELEASE_KEY") == "true"
|
||||
val releaseSigning = signingConfigs.getByName("release")
|
||||
val releaseStore = releaseSigning.storeFile
|
||||
signingConfig = when {
|
||||
releaseStore != null && releaseStore.isFile -> releaseSigning
|
||||
requireReleaseKey -> error(
|
||||
"Release keystore required but ANDROID_KEYSTORE_FILE is missing or not a file"
|
||||
)
|
||||
else -> {
|
||||
logger.warn(
|
||||
"No ANDROID_KEYSTORE_FILE; signing the release APK with the debug keystore. " +
|
||||
"CI must not do this — in-place upgrades will break."
|
||||
)
|
||||
signingConfigs.getByName("debug")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue