Skip to content

ci: verify the release tag before its scripts - #447

Merged
uniqueg merged 4 commits into
devfrom
ci/verify-release-tag
Nov 6, 2026
Merged

uniqueg merged 4 commits into
devfrom
ci/verify-release-tag

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Splits the release workflow's step "Check release tag and commit" the way Pubgrade-Sidecar does:

  • Check release tag and commit (id commit) runs first. It checks that the tag is annotated, that GitHub verified its signature and that the commit is on main, and outputs sha. It runs no code of the tagged commit.
  • Derive release version (id version) then runs scripts/release_version.py outputs, without GH_TOKEN.
  • The job output sha and the step "Check that CI passed for the release commit" now read steps.commit.outputs.sha. All steps.version.outputs.* references (version, prerelease, chart_version) are unchanged.
  • A new test, test_release_tag_checked_first, checks the step order and wiring:
    • only checkout and Python setup (with a fixed version only) come before the check;
    • the check holds the token and runs the signature check but no script, Python or file of the commit;
    • the version step runs scripts/release_version.py without the token (none at job level either).

The header comment and docs/development.md describe the checks but not their order, so they still match and are unchanged.

Closes #446

Verification

  • pytest tests/test_workflows.py: the new test fails on dev and passes on this branch (69 passed).
  • pre-commit run --all-files (includes actionlint, ruff, mypy, semgrep, gitleaks, ast-grep): passed.
  • CI: all checks passed (CI passed green; image push/publish, Trivy upload and integration jobs skipped on pull requests as intended).

Declined review findings

  • Adversarial review (low; raised on the identical change in cloud-registry): the tagged scripts still run before a later step in prepare that holds GH_TOKEN ("Check that CI passed for the release commit"), so a script could in principle tamper with $GITHUB_PATH/$GITHUB_ENV. This was already the case before this change. By then the tag is signed and its commit is on main, so the code is trusted. Moving the CI check would go beyond the reorder that ci: verify the release tag before running its scripts #446 asks for, and Pubgrade-Sidecar has the same order.
  • Quality review (low): the header comment and docs/development.md don't say that the tag checks run first. Neither describes the order of the steps, and the step comment documents it where the code is.

🤖 Generated with Claude Code

Summary by Sourcery

Verify release tags before running release-version scripts to prevent untrusted tagged code from executing prematurely.

Bug Fixes:

  • Verify the release tag and commit before executing tagged release scripts, ensuring only annotated, GitHub-verified tags on main can proceed.

Enhancements:

  • Separate release commit validation from release version derivation and use the validated commit SHA for downstream checks and job outputs.

Tests:

  • Add workflow coverage confirming tag validation ordering, token isolation, and output wiring.

uniqueg and others added 2 commits November 6, 2026 07:08
Split the step "Check release tag and commit" as in Pubgrade-Sidecar:
the tag checks (annotated, signature verified by GitHub, commit on
`main`) run first, in a step (id `commit`) that runs no code of the
tagged commit; `scripts/release_version.py` then runs in the new step
"Derive release version" (id `version`), without `GH_TOKEN`. The job
output `sha` and the CI check read `steps.commit.outputs.sha`. A test
checks the order and the wiring: only the checkout and Python setup
come before the tag check.

Closes #446

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Assert the exact steps before the tag check and that the check runs no
Python or file of the commit; let other steps sit between the check
and the version step. Raised by the pre-push review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The release workflow now verifies the annotated, GitHub-signed tag and its main commit before executing the tagged release-version script. SHA consumers are wired to the verification step, and regression tests enforce ordering and token isolation.

Sequence diagram for release tag verification before version derivation

sequenceDiagram
    participant Workflow as Release workflow
    participant Git as Git repository
    participant GitHub as GitHub API
    participant Script as release_version.py

    Workflow->>Git: git cat-file
    Workflow->>GitHub: gh api signature verification
    Workflow->>Git: git merge-base --is-ancestor
    Git-->>Workflow: verified commit SHA
    Workflow->>Script: python scripts/release_version.py outputs TAG
    Script-->>Workflow: version, prerelease, chart_version
Loading

File-Level Changes

Change Details Files
Separates release-tag verification from release-version derivation so tagged code runs only after the tag is validated.
  • Renames the verification step to commit and keeps the GitHub token scoped to its annotated-tag, signature, and main-commit checks.
  • Adds a token-free version step that invokes scripts/release_version.py after verification.
  • Updates the job output and CI-success lookup to use steps.commit.outputs.sha.
  • Adds workflow tests covering step ordering, token scoping, verification checks, and output wiring.
.github/workflows/release.yml
tests/test_workflows.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Assert that the tag check runs the signature check and the version step
runs `scripts/release_version.py`, that the job has no `GH_TOKEN`, and
say why Python setup may only get a fixed version. Raised by the
pre-push review.

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

codecov Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (85805bb) to head (7dd04dd).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #447   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           24        24           
  Lines         2685      2685           
=========================================
  Hits          2685      2685           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@uniqueg
uniqueg marked this pull request as ready for review November 6, 2026 06:38

@sourcery-ai sourcery-ai Bot 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="tests/test_workflows.py" line_range="300" />
<code_context>
+    check = steps["Check release tag and commit"]
+    assert check["id"] == "commit"
+    assert "GH_TOKEN" in check["env"]
+    assert ".verification.verified" in check["run"]
+    # Neither scripts nor Python nor other files of the commit
+    for code in ("scripts/", "python", "./"):
</code_context>
<issue_to_address>
**Unverified tags pass the test**

When the verification marker appears in the run text without an effective signature check, when the tag-verification API call and its result check are removed but `.verification.verified` remains in a comment, `test_release_tag_checked_first` passes line 300 without verifying the tag signature.

Assert the API call and the condition that rejects an unverified response, or execute the step logic in a test.
</issue_to_address>

Linked issues

#446 ci: verify the release tag before running its scripts · 3 of 3 met

# Requirement Status Notes
1 Run the annotated-tag, verified-signature, and commit-on-main checks without executing code from the tagged commit. ✅ Met The commit step performs all three checks before Derive release version runs any tagged script.
2 Run tagged scripts only after the checks, in steps without tokens they do not need. ✅ Met Derive release version runs after the checks and has no GH_TOKEN; the job has no job-level token.
3 Keep the workflow header comment and docs/development.md consistent, if they describe the steps. ✅ Met Both describe the checks without specifying their order, so they remain consistent with the workflow.

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: tests/test_workflows.py:300


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test_workflows.py Resolved
Take the step names from the list of steps, not from a dict keyed by
name, so that a second step named "Check release tag and commit" can't
hide before the real one. Raised by Sourcery.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@uniqueg
uniqueg merged commit d237a18 into dev Nov 6, 2026
36 checks passed
@uniqueg
uniqueg deleted the ci/verify-release-tag branch November 6, 2026 07:59
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: verify the release tag before running its scripts

1 participant