Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,19 @@ jobs:
# keeps the secret out of the filesystem entirely, and keeps the signing configuration in one
# place instead of a second, divergent one in this workflow.
- name: Restore the signing key
if: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' }}
# No `if:` here on purpose. Conditioning a step on `secrets` is something the workflow
# parser is unhappy about, and the condition is not needed: a missing secret is a failure,
# not a reason to publish a differently-signed build. The check lives inside the script,
# where it is a plain shell test.
env:
KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
STORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
run: |
if [ -z "$KEYSTORE_BASE64" ]; then
echo "::error::RELEASE_KEYSTORE_BASE64 is not set, so the release would be signed with the debug key."
echo "::error::Add the keystore as a repository secret and re-run the release."
exit 1
fi
echo "$KEYSTORE_BASE64" | base64 -d > release-key.p12
# Written to $GITHUB_ENV, not echoed: the value goes into the file, not the log.
echo "STORE_FILE=$GITHUB_WORKSPACE/release-key.p12" >> "$GITHUB_ENV"
Expand All @@ -99,23 +107,13 @@ jobs:
echo "KEY_PASSWORD=$STORE_PASSWORD" >> "$GITHUB_ENV"
echo "the signing key has been restored"

- name: Refuse to publish without a signing key
# A release signed with the wrong key is worse than no release: it installs once and then
# refuses to update, and the user has to uninstall and lose their settings. Failing here
# is the point.
if: ${{ secrets.RELEASE_KEYSTORE_BASE64 == '' }}
run: |
echo "::error::RELEASE_KEYSTORE_BASE64 is not set, so the release would be signed with the debug key."
echo "::error::Add the keystore as a repository secret and re-run the release."
exit 1

- name: Build release APK
run: ./gradlew assembleRelease --stacktrace

- name: Verify the signature
# A release that is not signed with the release key is worse than no release: it installs
# once and then refuses to update. Checked here, before anything is published.
if: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' }}
run: |
APKSIGNER=$(ls "$ANDROID_HOME"/build-tools/*/apksigner | tail -1)
"$APKSIGNER" verify --print-certs app/build/outputs/apk/release/*.apk
Expand Down
Loading