Skip to content

ci(release): prefer a decdn.org key from KEYS in sign-release.sh - #2393

Merged
thiras merged 3 commits into
mainfrom
ci/2391-sign-release-decdn-key
Oct 9, 2026
Merged

thiras merged 3 commits into
mainfrom
ci/2391-sign-release-decdn-key

Conversation

@thiras

@thiras thiras commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

What

With DECDN_SIGNING_KEY unset, sign-release.sh resolves the signing key in this order:

  1. The @decdn.org key. Use the one secret key that can sign, has a live @decdn.org uid, and is published in KEYS.
  2. Any published key. If no key matches step 1, use the one secret key that can sign and is published in KEYS, whatever its uids.
  3. Otherwise stop. If a step finds two or more candidates, the script stops and lists every fingerprint. If no key qualifies, it stops too. It never falls back to "first key gpg lists".

DECDN_SIGNING_KEY still takes priority. The ==> Signing as <fpr> (<rule>) line names the rule that chose the key, so you see the choice before the passphrase prompt.

Closes #2391

Reviewer notes

  • Stricter fallback (step 2) than the issue first asked for. The original AC3 said the no-@decdn.org-key case should take "gpg's default key" as before. The review showed that this lets keyring order choose between two published keys, for example during key rotation. I updated AC3 in the issue to match.
  • What "published" means. A key counts as published only if KEYS lists it, does not mark it revoked, expired, invalid or disabled (field 2 r/e/i/d), and shows it can sign (S in field 12). It is KEYS's view that counts, not the local keyring's: a revocation published in KEYS but never imported locally still excludes the key. The final KEYS check uses the same set, so it holds DECDN_SIGNING_KEY to this rule too.
  • Address matching. The email is the one gpg's own <address> lookup uses: the text inside the uid's first <…>, whatever follows it, or else the whole uid as a bare address. The match is case-insensitive and anchored. Maintainer <[email protected]> (release key) matches. These do not match: decdn.org.example, notdecdn.org, eu.decdn.org, Name [email protected], and Two <[email protected]> <[email protected]>.
  • gpg errors are no longer hidden. Each key listing is captured in an assignment, so a gpg failure stops the script with gpg's own error output. An empty secret listing (empty keyring, or gpg-agent not running) gets its own message.
  • default-key is not read. gpg.conf's default-key is ignored, as it was before. The header and RELEASING.md now say so.
  • publish-crates.sh is out of scope, as the issue says.

Verification

  • pytest .github/scripts/tests -q: 169 passed, 27 of them new.
    • These run the real script against a scratch keyring, and every key gets an encryption subkey, like the real keys in KEYS.
    • Cases cover:
      • the order of keys in the keyring
      • two @decdn.org keys
      • one key with two @decdn.org uids
      • key rotation
      • a revocation published only in KEYS
      • look-alike and revoked uids
      • a co-maintainer key whose secret half you don't hold
      • the fallback's refusals
      • an empty keyring
      • an injected gpg failure
      • every DECDN_SIGNING_KEY path
  • Mutation sweep: 11 mutants, all killed. They target:
    • the matcher: subkey/primary fingerprint mix-ups, the anchors, case sensitivity
    • the validity filters
    • both ambiguity checks
    • the KEYS check
    • the swallowed listing error
  • shellcheck .github/scripts/sign-release.sh: clean.
  • Smoke test on a real maintainer keyring (personal key plus [email protected]), against the already published v0.0.1. It printed ==> Signing as DA75…AADB (decdn.org key from KEYS), verified the tag, then stopped at "already published", as expected.
  • pre-commit on the changed files: passed.
  • User-visible change: CHANGELOG.md entry added
  • PR title uses an allowed type

🤖 Generated with Claude Code

With DECDN_SIGNING_KEY unset, sign-release.sh now picks the one secret
key that has a live @decdn.org uid and is published in KEYS. Two such
keys stop the script with both fingerprints listed. With none, it falls
back to the first secret key gpg lists, and the KEYS check still rejects
an unpublished key. DECDN_SIGNING_KEY keeps priority, and the
"==> Signing as" line names the rule that chose the key.

The uid match is on the email (inside the last <...>, or a bare
address), anchored on @decdn.org, and skips revoked/expired keys and
uids. The KEYS keyring is built before key selection, since the new
rule reads it.

A pytest suite runs the real script against a scratch keyring and KEYS,
covering keyring order, ambiguity, fallback, look-alike domains, revoked
uids and the DECDN_SIGNING_KEY override.

Closes #2391

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 9, 2026 12:12
@thiras thiras self-assigned this Oct 9, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The UID parser does not implement the documented last-angle-bracket matching rule when text follows the email.

1 open finding
What changed in this PR

Updates release signing to prefer a published @decdn.org secret key while preserving explicit overrides and fallback behavior.

Changes:

  • Adds deterministic signing-key selection and ambiguity handling.
  • Adds GPG-backed regression tests.
  • Updates release documentation and changelog.
File Description
.github/​scripts/​sign-release.sh Implements key discovery and selection rules.
.github/​scripts/​tests/​test_sign_release_key_selection.py Tests selection, ambiguity, validity, and fallback behavior.
RELEASING.md Documents the new selection order.
CHANGELOG.md Records the release-tooling change.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/scripts/sign-release.sh Resolved
Addresses the review of the sign-release.sh key selection:

- The fallback no longer takes the first secret key gpg lists. It takes
  the one secret key that can sign and is published in KEYS, and stops
  with every fingerprint listed when there are none or several.
- A key that KEYS marks revoked, expired, invalid or disabled, or that
  has no usable signing capability, counts as unpublished, even when
  the local copy still looks live. The final KEYS check uses the same
  set, so DECDN_SIGNING_KEY is held to it too.
- Key listings are captured in assignments, so a gpg failure stops the
  script with gpg's own error instead of reading as "no key" or "not in
  KEYS". An empty secret listing gets its own message.
- The @decdn.org match takes the email only from a <...> that ends the
  uid, and otherwise needs a bare address with no spaces or brackets.
- Comments describe what the code does: no claim that the fallback is
  gpg's own choice, gpg.conf's default-key is noted as unread, and the
  test fixture's socket-path rationale names /run/user/<uid>.

Tests now generate keys with an encryption subkey, like the real keys in
KEYS. They add cases for key rotation, a revocation published only in
KEYS, two @decdn.org uids on one key, a co-maintainer key without its
secret, an empty keyring, an injected gpg failure, and the fallback's
refusals. A mutation sweep of 11 mutants over the matcher, the
validity filters, both ambiguity checks, the KEYS check and the listing
error path kills all 11.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The @decdn.org match took the email from a <...> only when it ended the
uid, so `Maintainer <[email protected]> (release key)` did not match, although
gpg's own `<[email protected]>` lookup finds that uid. gpg takes the FIRST
<...> regardless of what follows it, so `Two <[email protected]> <[email protected]>` has
the email [email protected] to gpg; the old end-anchored rule read [email protected].

The script now takes the first <...>, matching gpg in both cases. Tests
cover a uid with text after the address and a uid with two <...> pairs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-code-quality

github-code-quality Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit e9a2e8a in the ci/2391-sign-release... branch remains at 75%, unchanged from commit e7eee84 in the main branch.

Show a line coverage summary of the most impacted files.
File main e7eee84 ci/2391-sign-release... e9a2e8a +/-
crates/client/src/sink.rs 95% 93% -2%
crates/client/src/streamer.rs 84% 83% -1%
crates/cache/src/engine.rs 91% 91% 0%
crates/protocol/src/framing.rs 93% 93% 0%
crates/client/src/lib.rs 88% 89% +1%
crates/node/src...s/client/mod.rs 89% 90% +1%

Solidity / code-coverage/forge

The overall line coverage in commit e9a2e8a in the ci/2391-sign-release... branch remains at 92%, unchanged from commit b468cad in the main branch.


Updated October 09, 2026 13:12 UTC

@thiras
thiras merged commit 8768ee9 into main Oct 9, 2026
55 of 57 checks passed
@thiras
thiras deleted the ci/2391-sign-release-decdn-key branch October 9, 2026 13:15
thiras added a commit to decdn/sponsord that referenced this pull request Oct 9, 2026
Port decdn/decdn#2393. With SPONSORD_SIGNING_KEY unset, sign-release.sh
used gpg's first secret key, so a maintainer keyring whose personal key
sorts first died at the KEYS check (as v0.0.1's signing did). It now
picks the one secret key that can sign, has a live @decdn.org uid and is
published in KEYS, else the one published secret key whatever its uids.
Two or more candidates at either step stop the script with every
fingerprint listed. A key KEYS marks revoked or expired counts as
unpublished, gpg failures while listing keys are reported instead of
reading as "no key", and "==> Signing as" names the rule that chose the
key. SPONSORD_SIGNING_KEY keeps priority.

The KEYS keyring is now built before key selection, which reads it. The
pytest suite from decdn runs the real script against a scratch keyring.

Co-authored-by: Claude Opus 5.5 <[email protected]>
thiras added a commit to decdn/sponsord that referenced this pull request Oct 9, 2026
Port decdn/decdn#2393. With SPONSORD_SIGNING_KEY unset, sign-release.sh
used gpg's first secret key, so a maintainer keyring whose personal key
sorts first died at the KEYS check (as v0.0.1's signing did). It now
picks the one secret key that can sign, has a live @decdn.org uid and is
published in KEYS, else the one published secret key whatever its uids.
Two or more candidates at either step stop the script with every
fingerprint listed. A key KEYS marks revoked or expired counts as
unpublished, gpg failures while listing keys are reported instead of
reading as "no key", and "==> Signing as" names the rule that chose the
key. SPONSORD_SIGNING_KEY keeps priority.

The KEYS keyring is now built before key selection, which reads it. The
pytest suite from decdn runs the real script against a scratch keyring.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci(release): sign-release.sh should prefer a decdn.org key before gpg's default key

2 participants