Skip to content

Commit 59edea6

Browse files
committed
fix: sign the release APK in Gradle instead of the signing action
The r0adkll signing action needs an old build-tools version that isn't on the runners anymore. Move signing into the Gradle release config, fed by the keystore secrets, so it uses whatever build-tools the build already needs. Local builds without the secrets stay unsigned and keep working.
1 parent 5fd33ef commit 59edea6

2 files changed

Lines changed: 30 additions & 23 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,36 +28,24 @@ jobs:
2828
- name: Set up Gradle
2929
uses: gradle/actions/setup-gradle@v4
3030

31-
- name: Build release APK
31+
# Gradle signs the release APK directly using the keystore from secrets, so
32+
# there's no dependency on a specific build-tools version being preinstalled.
33+
# Set the four secrets under Settings > Secrets and variables > Actions.
34+
- name: Build signed release APK
35+
env:
36+
KEYSTORE_FILE: ${{ runner.temp }}/keystore.jks
37+
KEYSTORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
38+
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
39+
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
3240
run: |
41+
echo "${{ secrets.SIGNING_KEY }}" | base64 -d > "$KEYSTORE_FILE"
3342
chmod +x ./gradlew
3443
./gradlew :app:assembleRelease --no-daemon
3544
36-
# Signs the unsigned release APK when the four signing secrets are present.
37-
# Set them under Settings > Secrets and variables > Actions. See the README /
38-
# docs for how to generate the keystore. Without them this step is skipped and
39-
# the unsigned APK is published instead (fine for a first internal test).
40-
- name: Sign APK
41-
id: sign
42-
if: ${{ env.SIGNING_KEY != '' }}
43-
uses: r0adkll/sign-android-release@v1
44-
env:
45-
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
46-
with:
47-
releaseDirectory: app/build/outputs/apk/release
48-
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
49-
alias: ${{ secrets.KEY_ALIAS }}
50-
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
51-
keyPassword: ${{ secrets.KEY_PASSWORD }}
52-
5345
- name: Collect APK
5446
run: |
5547
mkdir -p out
56-
if [ -n "${{ steps.sign.outputs.signedReleaseFile }}" ]; then
57-
cp "${{ steps.sign.outputs.signedReleaseFile }}" out/FocusForcePlus-${{ github.ref_name }}.apk
58-
else
59-
cp app/build/outputs/apk/release/app-release-unsigned.apk out/FocusForcePlus-${{ github.ref_name }}-unsigned.apk
60-
fi
48+
cp app/build/outputs/apk/release/app-release.apk "out/FocusForcePlus-${{ github.ref_name }}.apk"
6149
6250
- name: Publish to release
6351
uses: softprops/action-gh-release@v2

app/build.gradle.kts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,32 @@ android {
2323
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2424
}
2525

26+
signingConfigs {
27+
create("release") {
28+
// Populated from environment variables in CI (see .github/workflows/release.yml).
29+
// Left empty for local builds, which then produce an unsigned release APK.
30+
System.getenv("KEYSTORE_FILE")?.let { path ->
31+
storeFile = file(path)
32+
storePassword = System.getenv("KEYSTORE_PASSWORD")
33+
keyAlias = System.getenv("KEY_ALIAS")
34+
keyPassword = System.getenv("KEY_PASSWORD")
35+
}
36+
}
37+
}
38+
2639
buildTypes {
2740
release {
2841
isMinifyEnabled = false
2942
proguardFiles(
3043
getDefaultProguardFile("proguard-android-optimize.txt"),
3144
"proguard-rules.pro"
3245
)
46+
// Sign only when CI provided the keystore; otherwise stay unsigned.
47+
signingConfig = if (System.getenv("KEYSTORE_FILE") != null) {
48+
signingConfigs.getByName("release")
49+
} else {
50+
null
51+
}
3352
}
3453
}
3554
compileOptions {

0 commit comments

Comments
 (0)