Skip to content

Commit 37f4223

Browse files
graycreateclaude
andcommitted
fix: Make release signing configuration lazy to fix CI builds
- Remove exception throwing during configuration phase - Add task validation to check signing config only when building release - This fixes CI failures for dependabot PRs that don't have access to secrets 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent be95cd4 commit 37f4223

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

app/build.gradle

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@ android {
2424
release {
2525
// Release signing requires environment variables to be set
2626
// The keystore will be decoded from KEYSTORE_BASE64 in CI/CD
27-
if (System.getenv("KEYSTORE_PASSWORD") != null && System.getenv("KEY_PASSWORD") != null) {
28-
storeFile file("keystore.jks")
29-
storePassword System.getenv("KEYSTORE_PASSWORD")
30-
keyAlias System.getenv("KEY_ALIAS")?.trim() ?: "ghui"
31-
keyPassword System.getenv("KEY_PASSWORD")
32-
} else {
33-
// Release builds require proper environment variables
34-
throw new GradleException("Release builds require signing configuration. Please set KEYSTORE_PASSWORD and KEY_PASSWORD environment variables.")
35-
}
27+
storeFile file("keystore.jks")
28+
storePassword System.getenv("KEYSTORE_PASSWORD") ?: ""
29+
keyAlias System.getenv("KEY_ALIAS")?.trim() ?: "ghui"
30+
keyPassword System.getenv("KEY_PASSWORD") ?: ""
3631
}
3732
}
3833

@@ -128,4 +123,18 @@ dependencies {
128123
implementation 'com.github.oasisfeng:condom:2.5.0'
129124
implementation 'org.slf4j:slf4j-nop:1.7.25'
130125
implementation 'androidx.core:core-splashscreen:1.0.1'
126+
}
127+
128+
// Validate release signing configuration before building release
129+
tasks.whenTaskAdded { task ->
130+
if (task.name.contains('assembleRelease') || task.name.contains('bundleRelease')) {
131+
task.doFirst {
132+
def keystorePassword = System.getenv("KEYSTORE_PASSWORD")
133+
def keyPassword = System.getenv("KEY_PASSWORD")
134+
135+
if (!keystorePassword || !keyPassword) {
136+
throw new GradleException("Release builds require signing configuration. Please set KEYSTORE_PASSWORD and KEY_PASSWORD environment variables.")
137+
}
138+
}
139+
}
131140
}

0 commit comments

Comments
 (0)