From 17bbb20b94c70351e72b22c7513b0f3e8dba33e2 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Mon, 8 Jun 2026 23:15:38 -0700 Subject: [PATCH] build(android): guard release signing to allow keyless compile checks Release builds now use the real upload key when key.properties is present, fall back to debug signing only when ALLOW_DEBUG_SIGNED_RELEASE is set (CI compile-only checks), and otherwise fail loudly. Lets CI compile a release APK without production secrets while ensuring a real release can never be silently debug-signed if the keystore step goes missing. Co-Authored-By: Claude Opus 4.8 (1M context) --- android/app/build.gradle.kts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts index c9f675d5..596b2812 100644 --- a/android/app/build.gradle.kts +++ b/android/app/build.gradle.kts @@ -50,7 +50,16 @@ android { buildTypes { release { - signingConfig = signingConfigs.getByName("release") + // Use the real upload key when key.properties is present (release + // workflows create it from secrets). Allow debug signing only when a CI + // compile-only check explicitly opts in via ALLOW_DEBUG_SIGNED_RELEASE; + // otherwise fail loudly so a real release can never be silently + // debug-signed if the keystore step is ever missing. + signingConfig = when { + keystorePropertiesFile.exists() -> signingConfigs.getByName("release") + System.getenv("ALLOW_DEBUG_SIGNED_RELEASE") != null -> signingConfigs.getByName("debug") + else -> error("key.properties missing — set ALLOW_DEBUG_SIGNED_RELEASE=1 for compile-only builds") + } } } }