From 6f41ae58db7b17b716231a91cdbd94a90e2291af Mon Sep 17 00:00:00 2001 From: xXJSONDeruloXx Date: Thu, 24 Sep 2026 20:16:28 -0400 Subject: [PATCH] Use the pinned release signer for PR APKs --- .github/workflows/build.yml | 5 +++-- .github/workflows/pr-release-publish.yml | 11 +++++++---- .github/workflows/sign.yml | 6 +++--- tools/release/make-release-key.sh | 3 ++- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 228ef26f72..b2bebb92a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -499,8 +499,9 @@ jobs: # An apk is a zip already; compressing it again buys nothing and costs seconds. compression-level: 0 - # Only main is signed with DroidDeck's private key. Pull requests and other branches keep the - # public AOSP testkey build, so unreviewed branch code never gets access to the release key. + # This workflow signs only main. PR build jobs keep using the public AOSP test key; the separate + # main-only approval workflow can later sign an approved PR artifact without running PR code with + # the release key. sign: needs: build if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main' diff --git a/.github/workflows/pr-release-publish.yml b/.github/workflows/pr-release-publish.yml index 165cec0cd0..439cbb1b24 100644 --- a/.github/workflows/pr-release-publish.yml +++ b/.github/workflows/pr-release-publish.yml @@ -200,18 +200,21 @@ jobs: - name: Verify the release signer and checksum env: - EXPECTED_SHA256: b241ea7d7e8180e2e58a8a2cc6e819eedc36eff5a0a04f382a34cabba4b5d3f0 APK_NAME: ${{ needs.authorize.outputs.apk_name }} run: | set -euo pipefail apk="signed/$APK_NAME" test -s "$apk" || { echo "::error::Signed APK is missing: $APK_NAME"; exit 1; } + expected_sha256=$(tr -d '[:space:]' < keystore/release-signer.sha256) + [[ "$expected_sha256" =~ ^[[:xdigit:]]{64}$ ]] || { + echo "::error::keystore/release-signer.sha256 is not a SHA-256 digest"; exit 1; + } sdk=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-}} [[ -n "$sdk" && -d "$sdk/build-tools" ]] || { echo "::error::Android build-tools are unavailable"; exit 1; } tools=$(find "$sdk/build-tools" -mindepth 1 -maxdepth 1 -type d | sort -V | tail -1) certs=$("$tools/apksigner" verify --min-sdk-version 28 --print-certs "$apk") digest=$(sed -n 's/.*certificate SHA-256 digest: //p' <<<"$certs" | sort -u) - [[ "$digest" == "$EXPECTED_SHA256" ]] || { + [[ "$digest" == "$expected_sha256" ]] || { printf '%s\n' "$certs" >&2 echo "::error::PR APK is not signed with the release certificate"; exit 1; } @@ -226,7 +229,6 @@ jobs: APK_NAME: ${{ needs.authorize.outputs.apk_name }} SOURCE_REPO: ${{ github.repository }} TARGET_REPO: Droid-Deck/DroidDeck-CI - SIGNING_CERT_SHA256: b241ea7d7e8180e2e58a8a2cc6e819eedc36eff5a0a04f382a34cabba4b5d3f0 run: | set -euo pipefail if [ -z "$GH_TOKEN" ]; then @@ -236,6 +238,7 @@ jobs: pr=$(gh api "repos/$SOURCE_REPO/pulls/$PR_NUMBER") title=$(jq -r '.title' <<<"$pr" | tr '\r\n' ' ' | sed 's/[[:space:]]\+/ /g; s/ $//') url=$(jq -r '.html_url' <<<"$pr") + signing_cert_sha256=$(tr -d '[:space:]' < keystore/release-signer.sha256) tag="pr-$PR_NUMBER" notes=$(mktemp) trap 'rm -f "$notes"' EXIT @@ -244,7 +247,7 @@ jobs: printf 'Title: %s\n\n' "$title" printf 'Source PR: %s\n' "$url" printf "Source commit: \`%s\`\n" "$HEAD_SHA" - printf "Signed with DroidDeck release certificate SHA-256 \`%s\`.\n" "$SIGNING_CERT_SHA256" + printf "Signed with DroidDeck release certificate SHA-256 \`%s\`.\n" "$signing_cert_sha256" printf 'This is a review-approved test build. Back up app data before installing test builds.\n' } > "$notes" if view_out=$(gh api "repos/$TARGET_REPO/releases/tags/$tag" 2>&1); then diff --git a/.github/workflows/sign.yml b/.github/workflows/sign.yml index 01d72c111b..7445e2adf7 100644 --- a/.github/workflows/sign.yml +++ b/.github/workflows/sign.yml @@ -3,10 +3,10 @@ name: Sign APKs # Called, never run by itself: turns a "Build APK" apk into packages signed with DroidDeck's own key, # one matrix job per package in tools/release/variants.txt (tools/release/sign-apk.sh does the work # and checks it). The key lives only in the GitHub environment named by the caller: -# signing-main builds of main +# signing-main main builds and maintainer-approved PR artifacts # release manually dispatched release.yml from main -# PR CI stays test-key-only. The main-only PR Release Publish workflow may call this after it checks -# for an approving maintainer review, green CI, the exact current PR commit, and the stable versionCode. +# PR Build APK jobs stay test-key-only. PR Release Publish calls this from main only after approval, +# green CI, the exact current commit, and the stable versionCode have been checked. on: workflow_call: diff --git a/tools/release/make-release-key.sh b/tools/release/make-release-key.sh index cc1c241239..b707d833ba 100755 --- a/tools/release/make-release-key.sh +++ b/tools/release/make-release-key.sh @@ -4,7 +4,8 @@ # - The key is made on this device, in ~/droiddeck-release-key (outside the repo), with a long # random password written beside it. Nothing secret is printed. # - The key and password go to GitHub as secrets of the two signing environments -# (signing-main and release). Branch builds and pull requests keep using the public test key. +# (signing-main and release). PR build jobs use the public test key; a separate workflow signs +# an approved PR artifact from main. # - The key's certificate digest - public, not a secret - goes to keystore/release-signer.sha256, # which CI checks every signed apk against. That file is the only thing to commit. #