Skip to content

ci: add a dry-run mode to the release workflow - #513

Open
uniqueg wants to merge 7 commits into
devfrom
ci/release-dry-run
Open

uniqueg wants to merge 7 commits into
devfrom
ci/release-dry-run

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Closes #512

Summary

Adds a dry-run mode to release.yml, to replace dry runs in forks (first use: the 0.7.0 release, #510 / #511).

  • Mode from the event, not from an input: every event other than a pushed tag is a dry run (DRY_RUN: ${{ github.event_name != 'push' }}; steps test the event directly). New triggers: workflow_dispatch (no inputs: the version is the one in CITATION.cff, which the release checks require; a notice says when its tag exists already, as the generated notes are then those of that release) and pull_request for changes to the release workflow, its scripts, CITATION.cff and docs/releases/ (same-repo PRs only; fork PRs skip prepare and so the run).
  • Never enters the release environment (environment: ${{ github.event_name == 'push' && 'release' || '' }}), never logs in to Docker Hub, and never gets id-token or attestations permissions (the job that signs, release-image, runs for tag pushes only; see below).
  • Image: built and pushed by digest to a registry on the runner (registry:3.0.0, pinned by digest, localhost:5000/protes; Buildx on the host network with plain HTTP for that registry); its storage is passed to scan and publish as the artifact registry (1 day), so all jobs see the same digest; app version checked, digest scanned with the shared action, tags X.Y.Z/latest created there.
  • Chart: packaged and checked exactly as for the release (IMAGE_NAME stays the published image; registry operations use the new IMAGE_REF).
  • Skipped: the tag checks that need a tag (annotated, signed, on main), attestations and signatures (they would write to the public Rekor log); the "CI passed" check is a warning.
  • GitHub release: draft under dry-run-vX.Y.Z-<run id> at the commit (--target, notes with target_commitish; no Git tag is created for drafts), assets uploaded, draft updated, never published or marked latest; Delete dry-run release (always()) deletes only drafts of that tag and refuses other tags.
  • The real tag path is unchanged apart from names (TAG/RELEASE_TAG from prepare outputs, equal to github.ref_name there; IMAGE_REF equal to IMAGE_NAME there).
  • Docs: "Dry runs of the release" in docs/development.md.

Permissions: aligned with the org's pattern

Sourcery flagged that dry runs ran publish with id-token: write and attestations: write (job permissions can't depend on the event). Following the maintainer's decision ("align it with how we handle it in other PRs"), the workflow now follows the pattern of the other repos (read on dev on 2026-11-23):

  • Only jobs that run for pushes, in a protected environment, may sign. In every repo's CI, the jobs with id-token/attestations: write (publish, "Publish image") have if: github.event_name == 'push' and environment: dev-images; pull request runs get no write permission except security-events: write for SARIF (e.g. protes, prowes, tesk-api, tesk-core, foca, drs-filer, trs-filer, cloud-registry, krini, Pubgrade). Every release workflow runs only for tags, with workflow-level contents: read and per-job least privilege.
  • Signing in its own job, the GitHub release in a job without environment: release-image ("Release image", environment: release, contents: read, id-token/attestations: write) then publish ("Publish release", contents: write only), as in tesk-api, tesk-core, krini (also with the chart's Sigstore bundle passed as the artifact chart-signature, released with it in v0.1.0) and foca, and in the open landing-page#173 and the shared action of .github#85. protes, Pubgrade, cloud-registry, drs-filer, trs-filer and TESK still sign in one publish job, but none of them has a dry run, so the split is the only way to keep the push-only rule with one.
  • No other repo has a release dry run yet (cloud-components only passes --dry-run to npm in forks), so this PR remains the pilot of the design; it now matches the design's rule "never uses id-token".

What changed (bafcdf9, 3e550ab, 8e58ff8):

  • release-image (tag pushes only, if: github.event_name == 'push'): checks the chart and the release state, logs in, attests, signs and tags the image, attests and signs the chart, uploads the bundle (chart-signature) and outputs its SHA-256, and only then tags the image (as in krini, so that a failed chart signature leaves no tagged image).
  • publish (no environment; contents: write, pull-requests: read): runs after release-image, or without it in dry runs only (!cancelled() && needs.scan.result == 'success' && (release-image succeeded || dry run and release-image skipped)); checks the chart and, in releases, the bundle against their checksums; decides latest for the GitHub release right before creating it; in dry runs tags the image in the registry on the runner with the steps of release-image (a test pins them as identical).
  • Dry runs now get no id-token or attestations permission at all; their only write permission is contents: write of publish, for the draft release. Approvals per release stay two (push, release-image).
  • Tests: test_dry_run_permissions (only release-image may request id-token/attestations, exact permissions of release-image and publish), test_publish_after_release_image, test_release_chart_signature_passed, test_publish_chart_check_runs; the chart and release-state tests moved to release-image. Docs: "Versioning and releases" and "Dry runs of the release" in docs/development.md.

How it was verified

Declined review findings

  • Registry start script repeated in three jobs (quality, medium): kept inline, so that each job reads top to bottom like the rest of the workflow; test_dry_run_image_ref asserts that the three steps are identical.
  • Clean up dry-run-* drafts left by runs killed before their cleanup step (adversarial, low): clutter only (another tag name, hidden from the previous-release lookup); delete by hand if it ever happens.
  • Tag-image and latest steps written out in both release-image and publish (quality, medium): kept inline, like the registry start step; test_dry_run_image_ref and test_publish_after_release_image assert that the copies are identical.
  • The release-image -> publish hand-off (chart-signature artifact, bundle SHA-256 output, bundle branch of the chart check) is not exercised by dry runs (adversarial, medium): it can't be without signing. Its wiring is pinned by test_release_chart_signature_passed and test_publish_chart_check_runs, and it is the hand-off krini used for its v0.1.0 release. A fork run on a test tag would cover it; not done.
  • Image latest tag and GitHub latest release decided by two fetches of the tags (adversarial, low): they can differ only for stable releases (from 1.0.0; pre-releases are never marked latest) when another release is tagged between release-image and publish, and the next release moves both; krini decides them separately too.
  • contents: write on pull request dry runs (Sourcery, high): kept, it is the only write permission of a dry run and what the draft release needs; a same-repository pull request author has write access and can already run code with it by pushing a branch with a workflow of their own; publishing stays behind the release environment and the tag ruleset. The alternative, pull request dry runs without the draft release (read-only, draft only on workflow_dispatch), is the maintainer's call.

Decisions taken

  • No version input (review round 1): the citation check requires the version in CITATION.cff, so another version could only fail.
  • No dry_run input (the brief suggested one): an input that can't be false adds nothing, and a mode derived from the event can't be switched to a real release by mistake.
  • Permissions aligned with the other repos (maintainer, 2026-11-23: "Align it with how we handle it in other PRs"): signing only in a push-only job in the release environment, see "Permissions" above.
  • Attestation and signing are skipped rather than run with a throwaway key: keyless signing writes to the public transparency log, and key-based signing would test other commands than the release runs.

🤖 Generated with Claude Code

Summary by Sourcery

Add a safe, event-driven dry-run path that exercises releases end to end without publishing or exposing signing credentials.

New Features:

  • Add event-driven dry runs for the release workflow via manual dispatch and targeted pull requests, using the version from CITATION.cff.
  • Create temporary draft GitHub releases and locally registry-backed image releases for validation without publishing, tagging, signing, or entering the release environment.

Enhancements:

  • Separate release-only image attestation, signing, and chart signing from release publication while preserving digest and artifact verification.
  • Restrict signing permissions and release credentials to tag pushes, and pass the exact image and chart artifacts between jobs.
  • Document the dry-run workflow and its safety guarantees.

CI:

  • Expand workflow tests to cover dry-run triggers, permissions, image references, release creation, cleanup, chart validation, and job ordering.

Documentation:

  • Document how to run release dry runs and how they differ from real releases.

Tests:

  • Extend workflow coverage with dry-run behavior, permission, artifact handoff, release cleanup, and validation tests.

uniqueg and others added 3 commits November 22, 2026 10:41
Every event other than a pushed tag (workflow_dispatch with an optional
version, pull requests from branches of this repository that change the
release) runs the release as a dry run: no release environment, no
Docker Hub login, the image pushed by digest to a registry on the runner
and scanned and tagged there, no attestations or signatures, and the
GitHub release created as a draft of a throwaway tag that is never
published and is deleted at the end. Replaces dry runs in forks.

Closes #512

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop the version input (the citation check requires the version in
CITATION.cff anyway), note when that version is tagged already (the
generated notes are then those of that release), do not echo invalid
versions, test the safety properties over all jobs and the CI check of
dry runs, and correct comments and docs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uniqueg uniqueg added the type: ci / cd Related to continuous integration / delivery label Nov 22, 2026
@uniqueg uniqueg self-assigned this Nov 22, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Configuration

Add event-derived dry runs using a local registry and disposable draft releases, while isolating signing and attestations in a tag-only release-image job.

  • .github/workflows/release.yml L439-480, L608-637, L666-827 (+40 small edits)

Documentation

Document the release-image and publish job split and explain how to run and interpret release dry runs.

  • docs/development.md L570-582, L786-841 (+3 small edits)

Tests

Cover dry-run triggers, permissions, local image handling, draft creation and cleanup, and the release chart-signature handoff.

  • tests/test_workflows.py L468-512, L639-721, L872-1406 (+15 small edits)

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

@read-the-docs-community

read-the-docs-community Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 proTES | 🛠️ Build #36117599 | 📁 Comparing 8e58ff8 against latest (e1e311c)

  🔍 Preview build  

1 file changed
± development/index.html

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e1e311c) to head (8e58ff8).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #513   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines         3544      3544           
=========================================
  Hits          3544      3544           

☔ 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 22, 2026 11:02
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 8e58ff8

#512 ci: add a dry-run mode to the release workflow · 7 of 8 met

# Requirement Status Notes
1 Run dry runs on workflow_dispatch using the version in CITATION.cff by default, with an optional version input. 🟡 Partly met Dispatch runs use CITATION.cff, but workflow_dispatch has no version input.
2 Run dry runs for same-repository pull requests that change the release workflow or its scripts. ✅ Met The pull_request path filters cover the release workflow and scripts, and prepare skips fork pull requests.
3 Never enter the release environment or log in to Docker Hub during a dry run. ✅ Met The push job uses the release environment and logs in only for tag pushes; release-image also runs only for tag pushes.
4 Push the image by digest to a local registry, pass its storage between jobs, scan it, and create its version and latest tags there. ✅ Met Dry runs use a runner-local registry and pass its storage as an artifact to scan and publish.
5 Package and check the chart as for a release. ✅ Met The prepare job packages and checks the chart, and publish checks the downloaded chart against its recorded checksum.
6 Skip attestations and signatures in dry runs. ✅ Met The attesting and signing job is tag-push-only; BuildKit still adds SBOM and provenance data to the local image.
7 Skip tag-dependent checks in dry runs and make a missing successful CI run a warning. ✅ Met Dry runs skip the annotated, signed, and main-branch tag checks; a missing CI run emits a warning.
8 Create a draft release under a throwaway tag at the commit, attach assets and notes, never publish or mark it latest, and delete only its draft at the end. ✅ Met Dry runs use the generated dry-run tag and target commit, update the draft without publishing it, and clean up matching drafts with an always() step.

@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 8 issues

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

## Individual Comments

### Comment 1
<location path=".github/workflows/release.yml" line_range="57" />
<code_context>
     tags: ["v*"]
+  # Dry runs (see above)
+  workflow_dispatch:
+  pull_request:
+    paths:
+      - .github/workflows/release.yml
</code_context>
<issue_to_address>
**Unreviewed code gets release credentials**

When a same-repository pull request changes the workflow or release scripts, or dispatch selects a branch with altered release code, `publish` checks out and runs that code without the reviewer-gated environment while holding `contents: write`, `id-token: write`, and `attestations: write` credentials. The code can alter GitHub releases or create attestations, so the dry run is not an unprivileged test.

Keep PR- and dispatch-selected code from running with write, signing, or attestation credentials until it has passed the required reviewer approval.

Also at `.github/workflows/release.yml:58`, `.github/workflows/release.yml:106`, `.github/workflows/release.yml:465`.
</issue_to_address>

### Comment 2
<location path=".github/workflows/release.yml" line_range="804" />
<code_context>
-          TAG: ${{ github.ref_name }}
         run: |
           releases="$(mktemp)"
           gh api --paginate --slurp "repos/${GH_REPO}/releases?per_page=100" \
               > "${releases}"
-          state="$(python scripts/release_assets.py precheck "${TAG}" \
</code_context>
<issue_to_address>
**Failed cleanup appears successful**

When the releases API call fails during cleanup, for example because of a transient GitHub API error or rate limit, `gh api`'s failure is masked by the succeeding `jq`/empty `while` pipeline because this step does not enable `pipefail`; the workflow can report success while leaving the dry-run draft behind.

Enable `pipefail` for the cleanup pipeline or capture and check the API response before filtering it.
</issue_to_address>

### Comment 3
<location path=".github/workflows/release.yml" line_range="56" />
<code_context>
   push:
     tags: ["v*"]
+  # Dry runs (see above)
+  workflow_dispatch:
+  pull_request:
+    paths:
</code_context>
<issue_to_address>
**Optional version input**

The issue asks for a workflow_dispatch version input defaulting to CITATION.cff. Dispatch currently has no inputs, so it always uses the citation version.
</issue_to_address>

### Comment 4
<location path="tests/test_workflows.py" line_range="1016" />
<code_context>
+    )
+    assert output["tag"] == tag
+    assert output["release_tag"] == f"dry-run-{tag}-42"
+    assert re.fullmatch(r"[0-9a-f]{40}", output["sha"])
+
+
</code_context>
<issue_to_address>
**Wrong commit passes the SHA check**

When the tag-check step writes a valid-looking SHA other than `HEAD`, `test_dry_run_tag` only checks that the output SHA looks like a 40-character hash. A dry-run tag check that writes a different valid hash therefore passes, even though later jobs would check out and release the wrong commit.

Compare the output SHA with `git rev-parse HEAD` in the test.
</issue_to_address>

### Comment 5
<location path="tests/test_workflows.py" line_range="793-798" />
<code_context>
+    # No inputs: the version is the one in `CITATION.cff`
+    assert not events["workflow_dispatch"]
+    paths = events["pull_request"]["paths"]
+    assert ".github/workflows/release.yml" in paths
+    assert "scripts/release_*.py" in paths
+    assert "CITATION.cff" in paths
+    for path in paths:
+        if "*" not in path:
+            assert (ROOT / path).exists(), path
+    assert workflow["env"]["DRY_RUN"] == "${{ " + DRY_RUN + " }}"
+    # Pull requests from forks can't create the draft release
</code_context>
<issue_to_address>
**Release-note changes stop triggering runs**

When the pull-request path filter drops `docs/releases/**`, `test_release_triggers` only requires three path entries and checks that listed paths exist; its loop does not require `docs/releases/**`. The test therefore passes even though changes to release notes no longer trigger the workflow.

Assert that every required release path pattern, including `docs/releases/**`, is present.
</issue_to_address>

### Comment 6
<location path="tests/test_workflows.py" line_range="924" />
<code_context>
+        assert steps["Start local registry"] == start, job_id
+        download = steps["Download local registry"]
+        assert download["if"] == DRY_RUN
+        assert download["with"]["name"] == "registry"
+        names = list(steps)
+        assert names.index("Download local registry") < names.index(
</code_context>
<issue_to_address>
**Broken registry artifact paths pass**

When an upload or download artifact path no longer matches the local registry storage path, `test_dry_run_image_ref` checks artifact names but not their paths. If the upload or a download uses a different path from the registry storage started in each job, the test still passes even though `scan` and `publish` will not receive the pushed image.

Assert that the upload path and both download paths match the directory mounted by the registry-start steps.

Also at `tests/test_workflows.py:931`.
</issue_to_address>

### Comment 7
<location path="tests/test_workflows.py" line_range="881-882" />
<code_context>
+        },
+        check=False,
+    )
+    assert (result.returncode == 0) == passes, result.stdout + result.stderr
+    level = "::warning::" if passes else "::error::"
+    assert level in result.stdout
+
</code_context>
<issue_to_address>
**CI check can be skipped unnoticed**

When the CI-check step skips the GitHub API query and treats `runs` as empty, `test_ci_check_dry_run` only checks the exit status and annotation level. If the step stops querying GitHub and treats the result as zero, both cases still produce the expected warning or error, so the test passes while the CI check no longer detects successful runs.

Record calls in the `gh` stub and assert that the CI runs endpoint was queried.
</issue_to_address>

### Comment 8
<location path="docs/development.md" line_range="811" />
<code_context>
+- the chart is packaged and checked as for the release (with the published
+  image as its default);
+- nothing is attested or signed (both would add entries to the public
+  Sigstore transparency log);
+- the GitHub release is created as a draft of the tag
+  `dry-run-vX.Y.Z-<run ID>` at the commit (no Git tag is created for
</code_context>
<issue_to_address>
**Dry runs still emit provenance**

When a dry run builds the image, `Build and push image by digest` keeps `provenance: mode=max` enabled for dry runs, so BuildKit emits provenance alongside the image in the local registry. The docs promise that nothing is attested, leaving users with an inaccurate description of the dry-run artifact.

Clarify that dry runs skip GitHub attestations and Sigstore signatures, while the build still emits local BuildKit provenance and an SBOM.

Also at `docs/development.md:819`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 6 findings to address first, and same-repository pull requests now run the publish job without the release-environment approval, while that job has contents: write; PR-controlled workflow code can use the token to create releases or alter repository state. Those changes can persist after reverting this workflow, and the expanded write-token trust boundary is the key risk.

Blocking findings: .github/workflows/release.yml:57, .github/workflows/release.yml:804, tests/test_workflows.py:1016, tests/test_workflows.py:798, tests/test_workflows.py:924, and 1 more


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

Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread tests/test_workflows.py Resolved
Comment thread tests/test_workflows.py Resolved
Comment thread tests/test_workflows.py Resolved
Comment thread tests/test_workflows.py Resolved
Comment thread docs/development.md Resolved
uniqueg and others added 3 commits November 22, 2026 12:21
Fail the dry-run cleanup on a failed request (pipefail), say that
BuildKit still adds its SBOM and provenance to the local image, and
make the tests check the SHA, the release-notes path, the registry
artifact paths and the CI query.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dry runs (any event but a pushed tag) ran `publish` with
`id-token: write` and `attestations: write`, as job permissions can't
depend on the event. Align with the org's pattern instead: only jobs
that run for pushes, in a protected environment, may sign (the dev
image jobs of every repo's CI; the `Release image` job of tesk-api,
tesk-core, krini and foca).

- New job `release-image` (tag pushes only, environment `release`):
  checks the chart and the release state, attests, signs and tags the
  image, attests and signs the chart, and passes the chart's Sigstore
  bundle (with its SHA-256) to `publish`.
- `publish` keeps only `contents: write` (and `pull-requests: read`),
  runs without environment, checks the chart and the bundle, and
  creates the release; in dry runs it decides `latest` and tags the
  image in the registry on the runner, with the steps of
  `release-image`.
- Approvals stay two per release (`push`, `release-image`).
- Tests: no job but `release-image` may request `id-token` or
  `attestations`; `publish` runs after `release-image` or, in dry runs
  only, without it; the publish chart check with and without bundle.
- Docs: "Versioning and releases" and "Dry runs of the release".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
- `publish` decides `latest` for the GitHub release itself, also in
  releases, so that a re-run of `publish` alone decides from the
  current tags (not from an older output of `release-image`).
- `release-image` links the deployment to the release page (`url:`),
  as the old `publish` environment did.
- Tests: tampered chart in the publish chart check; exact permissions
  of `release-image`.
- Docs and comments: name the jobs of each approval, rewrap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5
@uniqueg

uniqueg commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

@sourcery-ai review

@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 8 issues

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

## Individual Comments

### Comment 1
<location path=".github/workflows/release.yml" line_range="681" />
<code_context>
       name: release
       url: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ github.ref_name }}
     permissions:
-      contents: write # create the GitHub release
-      pull-requests: read # list the pull requests of a first release
+      contents: read
</code_context>
<issue_to_address>
**Dry runs expose release-write access**

When a contributor with access to create a same-repository PR changes the release workflow or an invoked release script, `publish` checks out the PR merge SHA and runs its release scripts while `GH_TOKEN` is available and the job has `contents: write`; a same-repository PR author can therefore use PR-controlled code to publish or alter GitHub releases without the protected `release` environment.

Do not run PR-controlled code with a write-capable token; keep PR dry runs read-only or separate the draft-release operation so it only runs trusted code with `contents: write`.

Also at `.github/workflows/release.yml:698`, `.github/workflows/release.yml:863`.
</issue_to_address>

### Comment 2
<location path=".github/workflows/release.yml" line_range="64-70" />
<code_context>
+  workflow_dispatch:
+  pull_request:
+    paths:
+      - .github/workflows/release.yml
+      - scripts/release_*.py
+      - scripts/chart_readme.py
+      - scripts/check_release_pins.py
+      - scripts/citation.py
+      - CITATION.cff
+      - docs/releases/**

 permissions:
</code_context>
<issue_to_address>
**Chart changes skip release dry runs**

When a pull request changes a release-relevant chart input such as `deployment/Chart.yaml` or `deployment/values.yaml`, a pull request that changes files under `deployment/` does not match these paths, so the release workflow never exercises its chart packaging and release-specific checks for that change; the PR can merge without that end-to-end validation.

Include the release-relevant `deployment/` paths in the pull-request trigger, or otherwise ensure chart changes run the release dry run.
</issue_to_address>

### Comment 3
<location path=".github/workflows/release.yml" line_range="631" />
<code_context>
           fi
           for tag in "${tags[@]}"; do
-              docker buildx imagetools create --tag "${tag}" "${IMAGE_NAME}@${DIGEST}"
+              docker buildx imagetools create --tag "${tag}" "${IMAGE_REF}@${DIGEST}"
               actual="$(docker buildx imagetools inspect "${tag}" \
                   --format '{{ json .Manifest }}' | jq -r .digest)"
</code_context>
<issue_to_address>
**Older release overwrites latest image**

When two releases overlap and the older run checks tags before the newer tag appears, then writes its image tag afterward, `release-image` uses a stale latest decision when tagging the image, while `publish` independently selects the newer GitHub release as latest. Docker Hub’s `latest` then points to the older digest, so users see different latest versions for the image and GitHub release.

Serialize release image tagging with other releases, or refresh the latest decision immediately before tagging and use a consistent decision for the GitHub release.

Also at `.github/workflows/release.yml:806`, `.github/workflows/release.yml:928`.
</issue_to_address>

### Comment 4
<location path=".github/workflows/release.yml" line_range="631" />
<code_context>
           fi
           for tag in "${tags[@]}"; do
-              docker buildx imagetools create --tag "${tag}" "${IMAGE_NAME}@${DIGEST}"
+              docker buildx imagetools create --tag "${tag}" "${IMAGE_REF}@${DIGEST}"
               actual="$(docker buildx imagetools inspect "${tag}" \
                   --format '{{ json .Manifest }}' | jq -r .digest)"
</code_context>
<issue_to_address>
**Failed chart signing leaves image tagged**

When a chart attestation, signing, or signature-upload step fails after `Tag image` succeeds, the image version and possibly `latest` tags are written before chart attestation, signing, and signature upload finish. If one of those later steps fails, `release-image` fails and `publish` does not run, leaving a publicly tagged image without the corresponding GitHub release and chart signature.

Add compensating cleanup for the image tags on a later release-image failure, or defer the public tag mutation until the remaining release-image steps have succeeded.

Also at `.github/workflows/release.yml:656`.
</issue_to_address>

### Comment 5
<location path=".github/workflows/release.yml" line_range="883" />
<code_context>
           notes_file="$(mktemp)"
+          target=()
+          if [[ "${DRY_RUN}" == "true" ]]; then
+              target=(-f "target_commitish=${SHA}")
+          fi
           if [[ -n "${PREVIOUS}" ]]; then
</code_context>
<issue_to_address>
**First-release notes include later changes**

When the dry run's version tag already exists, there is no previous published release, and the run's HEAD is later than the tag's commit, when there is no previous published release, `Create release` takes the `release_notes.py first` branch and builds its commit history from `git rev-list HEAD`, not from the existing version tag. A dry run on a later commit therefore includes changes made after that tagged release, so its notes differ from the release being previewed.

When the version tag exists, generate first-release notes from that tag's commit history rather than the dry-run HEAD's history.
</issue_to_address>

### Comment 6
<location path=".github/workflows/release.yml" line_range="806" />
<code_context>
+          # The highest stable release among the tags on `main`, so that stray
+          # tags are ignored
+          git tag -l 'v*' --merged origin/main \
+              | python scripts/release_version.py latest "${TAG}" >> "${GITHUB_OUTPUT}"
+      - name: Tag image
+        if: github.event_name != 'push'
</code_context>
<issue_to_address>
**Dry runs skip latest image tagging**

When a dry run tests a stable version before its version tag has been pushed, `release_version.py latest` returns false because the candidate tag is absent from the tags on `main`, so `Tag image` does not add the `latest` tag. The dry run therefore misses the latest-tagging behavior it is meant to exercise.

Include the dry-run candidate when determining whether to add the `latest` image tag.

Also at `.github/workflows/release.yml:814`.
</issue_to_address>

### Comment 7
<location path=".github/workflows/release.yml" line_range="61" />
<code_context>
   push:
     tags: ["v*"]
+  # Dry runs (see above)
+  workflow_dispatch:
+  pull_request:
+    paths:
</code_context>
<issue_to_address>
**Optional version input**

The issue asks for `workflow_dispatch` to accept an optional version, defaulting to CITATION.cff. The change defines dispatch without inputs and always reads the citation version, so callers cannot select a version.
</issue_to_address>

### Comment 8
<location path="tests/test_workflows.py" line_range="964-967" />
<code_context>
+        for name, step in steps.items():
+            if name in names:
+                continue
+            text = yaml.safe_dump(step)
+            assert "secrets." not in text, (job_id, name)
+            assert "attest-build-provenance" not in text, (job_id, name)
+            assert "cosign sign" not in text, (job_id, name)
+
+
</code_context>
<issue_to_address>
**Job-level secrets escape checks**

When a secret is added to a non-release job’s job-level `env`, `test_dry_run_skips_release_steps` serializes each step at lines 961–965 but never checks the job configuration, so a secret moved into a non-release job’s `env` is inherited by its dry-run steps and the test still passes.

Check each non-release job’s configuration for secret references as well as checking its steps.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 8 findings to address first, and same-repository pull requests run the modified workflow with contents: write in publish, without the release-environment approval. A PR that changes the workflow can use that token to write repository contents or create releases; reverting the workflow cannot undo those writes.

Blocking findings: .github/workflows/release.yml:681, .github/workflows/release.yml:70, .github/workflows/release.yml:631, .github/workflows/release.yml:631, .github/workflows/release.yml:883, and 3 more


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

Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread tests/test_workflows.py Resolved
Address Sourcery review findings of the release-image split:

- `release-image` attests and signs the chart (and uploads its
  bundle) before it tags the image, so that a failure there leaves no
  tagged image without a signed chart, as in krini.
- Pull requests that change the chart (`deployment/**`) run the dry
  run too.
- Test: jobs other than `release-image` reference no secret outside
  their steps either (e.g. in a job-level `env`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011FSoqN5w1v5t1QRTKU7ad5

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: ci / cd Related to continuous integration / delivery

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: add a dry-run mode to the release workflow

1 participant