Skip to content

feat: sign pin commits and guard draft releases in the pin pr flow - #22

Merged
nullPointerEnjoyer merged 2 commits into
mainfrom
fix/release-pipeline-hardening
Nov 28, 2026
Merged

nullPointerEnjoyer merged 2 commits into
mainfrom
fix/release-pipeline-hardening

Conversation

@nullPointerEnjoyer

Copy link
Copy Markdown
Collaborator

Replaces #21 (GitHub's PR head association broke when the branch was recreated; fresh PR from the same signed commits).

Root-cause fixes for the two manual-firefight loops this release cycle hit on every tag:

1. Signed pin commits. The workflow-authored pin commit was unsigned, so the default-branch commit-signature ruleset blocked every pin PR (#13/#19 both needed a manual signed re-author). open-spm-pr.sh now SSH-signs the pin commit when BOT_SIGNING_KEY (SSH private key) is configured — key written 0600, an EXIT trap removes it on every path (a failed signed commit can no longer strand the key), signing rides on one-shot -c options so no repo config is mutated. Without the secret the behavior is unchanged. release.yml passes the optional secret through.

Owner action to activate signing (one time): create an SSH keypair, register the public key as a signing key on the repository (or bot account), and add the private key as the BOT_SIGNING_KEY actions secret.

2. Draft-release guard. Hoisted to the input-validation section: the script verifies the release is published before ANY local mutation and fails closed with an actionable message (publish command included), instead of the opaque pin-gate refusal three days later.

Tests: suite extended 164 → 168 assertions (draft refusal + message, unreadable state fail-closed, signed commit invocation with one-shot signing config, unsigned fallback unchanged). actionlint + shellcheck clean. Addresses both review threads from #21.

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 2 issue(s) in this PR.

  • ✅ Successfully posted inline: 0 comment(s)
  • 📋 Routed to summary by policy: 2 comment(s)

maintainability · low

📄 scripts/release/open-spm-pr.sh (L72-L74)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

Suppressing gh's stderr entirely (2>/dev/null) makes every failure mode — missing tag, transient API error, auth failure — report the same generic 'cannot verify the release state' message. During a real release this makes it hard to tell whether the tag was never pushed versus a transient GitHub outage. Consider capturing gh's output and including it in the error line, e.g. err="$(gh release view ... 2>&1)" || { echo "::error::cannot verify ...: ${err}"; exit 1; }.

💡 Suggested Change

Before:

release_is_draft="$(gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" \
  --json isDraft --jq '.isDraft' 2>/dev/null)" \
  || { echo "::error::cannot verify the release state for $(esc "${TAG}")"; exit 1; }

After:

gh_err="$(gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" \
  --json isDraft --jq '.isDraft' 2>&1)" \
  || { echo "::error::cannot verify the release state for $(esc "${TAG}"): ${gh_err}"; exit 1; }
release_is_draft="${gh_err}"

maintainability · low

📄 scripts/release/open-spm-pr.sh (L75-L78)

⚠️ GitHub could not post this as an inline comment: Routed to summary (severity low · category maintainability)

When gh release view succeeds but .isDraft comes back empty (e.g., unexpected JSON shape or an empty jq result), this check fails with the message "release ${TAG} is a draft", which is factually wrong and can mislead during a real release. An empty value is an unknown state, not a draft; the error should distinguish it (e.g., "unexpected release state: ") or the empty case should fall into the "cannot verify" path.

💡 Suggested Change

Before:

if [ "${release_is_draft}" != "false" ]; then
  echo "::error::release $(esc "${TAG}") is a draft; publish it (gh release edit $(esc "${TAG}") --draft=false) before opening the pin pr"
  exit 1
fi

After:

if [ -z "${release_is_draft}" ]; then
  echo "::error::cannot verify the release state for $(esc "${TAG}")"
  exit 1
fi
if [ "${release_is_draft}" != "false" ]; then
  echo "::error::release $(esc "${TAG}") is a draft; publish it (gh release edit $(esc "${TAG}") --draft=false) before opening the pin pr"
  exit 1
fi

@nullPointerEnjoyer
nullPointerEnjoyer merged commit 13cf162 into main Nov 28, 2026
22 checks passed
@nullPointerEnjoyer
nullPointerEnjoyer deleted the fix/release-pipeline-hardening branch November 28, 2026 14:14
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.

2 participants