Repository navigation
ci: check tag signature and released versions - #819
Conversation
The release workflow now fails unless the tag is annotated and has a signature that GitHub verified, and before anything is built if the version is already on PyPI or has an image tag on Docker Hub (a mistaken tag, or "Re-run all jobs" after a partial release). release-image fails before it attests, signs or tags anything if an image tag of the version points to another digest. As in proTES. Closes #818 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Match only the registry's exact answer for a missing image tag, note what the version check can't detect, document signing keys and re-runs of failed lookups, and test the branch check and the gh call. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move origin/main with fixed git arguments, as the push hook's semgrep rule flags a subprocess call with a computed commit SHA. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideConfigurationRequire release tags to be annotated, named correctly, and verified by GitHub; check that versions are absent from PyPI and Docker Hub before building, and prevent published image tags from moving to a different digest.
DocumentationDocument the signing-key requirements, registry checks, and safe rerun behavior for releases.
TestsAdd tests for release-tag validation, version availability lookups, image-tag immutability, lookup failures, and check ordering.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #819 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 76 76
Lines 10708 10708
=========================================
Hits 10708 10708
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Linked issuesChecked at commit 536fdd4 #818 ci: check tag signature and existing release versions · 4 of 4 met
|
There was a problem hiding this comment.
Hey - I've found 6 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="91-93" />
<code_context>
+ echo "::error::Tag '${TAG}' is not annotated (git tag -s)"
+ exit 1
+ fi
+ verified="$(gh api "repos/${REPOSITORY}/git/tags/$(git rev-parse "refs/tags/${TAG}")" \
+ --jq .verification.verified)"
+ if [[ "${verified}" != "true" ]]; then
+ echo "::error::Tag '${TAG}' has no signature verified by GitHub (git tag -s)"
exit 1
</code_context>
<issue_to_address>
**Mismatched signatures authorize releases**
When a valid signed tag object is pushed under a different version-tag ref, the signature check verifies the object but not that its embedded tag name matches `TAG`; the workflow derives the version from the ref and accepts a release under a version the signer did not sign.
Check that the signed tag object's `.tag` matches `${TAG}` before accepting the signature.
</issue_to_address>
### Comment 2
<location path=".github/workflows/release.yml" line_range="462-474" />
<code_context>
+ if manifest="$(docker buildx imagetools inspect "${tag}" \
</code_context>
<issue_to_address>
**Existing image tags get overwritten**
When another publisher creates or moves a checked version tag after inspection but before `Tag image` runs, `docker buildx imagetools create --tag` writes the tag without a create-only condition, replacing the other publisher's digest; the post-write check then passes and the published tag moves without detection.
Make image-tag creation conditional so it fails rather than overwriting a tag that already exists.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release.yml" line_range="449" />
<code_context>
+ # meant to move. Only the registry's exact answer for a missing tag
+ # (`ERROR: <tag>: not found`, as of buildx 0.26) counts as "not
+ # found"; any other failed lookup fails the step
+ - name: Check image tags
+ env:
+ DIGEST: ${{ steps.digest.outputs.digest }}
</code_context>
<issue_to_address>
**Conflicting tags leave partial releases**
When a conflicting version tag appears after `prepare` checks Docker Hub and before `release-image` checks it, `pypi` has already published the immutable package when the image-tag check fails, leaving the release incomplete and the version unusable for a clean retry.
Run the image-tag check before publishing the package to PyPI.
Also at `.github/workflows/release.yml:127`.
</issue_to_address>
### Comment 4
<location path=".github/workflows/release.yml" line_range="161" />
<code_context>
+ # than one page fail, so that none is missed
+ if ! existing="$(jq -r --arg version "${VERSION}" '
+ if .next != null then error("more than one page of tags") else . end
+ | .results[].name
+ | select(. == $version or (startswith($version + "-py")
+ and (.[($version | length) + 3:] | test("^[0-9]+\\.[0-9]+$"))))
</code_context>
<issue_to_address>
**Malformed tag responses pass the release check**
When docker Hub returns HTTP 200 with valid JSON whose `results` field is missing, null, or not a usable array, `jq` treats `.results[].name` as producing no entries, so `existing` stays empty and `prepare` proceeds without verifying that matching tags are absent; the release can reuse a version that already has matching tags.
Validate that `results` is an array before reading its names, and fail the check if it is missing or has an unexpected shape.
Also at `.github/workflows/release.yml:162`.
</issue_to_address>
### Comment 5
<location path=".github/workflows/release.yml" line_range="127" />
<code_context>
+ # versions deleted from PyPI (whose file names PyPI still rejects) and
+ # tags in a private Docker Hub repository (e.g., of a fork; the API
+ # answers 404 as for a missing repository)
+ - name: Check that the version is not released yet
+ env:
+ VERSION: ${{ steps.version.outputs.version }}
</code_context>
<issue_to_address>
**Concurrent PyPI files are silently accepted**
When another publisher uploads files for this version after the lookup returns 404 and before this workflow uploads its distributions, pyPI's `skip-existing: true` accepts the pre-existing files without comparing their contents to this run's distributions, so the workflow can publish images for a different build while PyPI serves the concurrent publisher's files.
Make PyPI uploads reject existing files instead of silently skipping them, or otherwise ensure conflicting concurrent uploads cannot be accepted.
Also at `.github/workflows/release.yml:137`, `.github/workflows/release.yml:449`.
</issue_to_address>
### Comment 6
<location path="tests/test_release_workflow.py" line_range="297-299" />
<code_context>
+
+ def test_no_release_version(self, repo: Path, bin_dir: Path) -> None:
+ """A tag that is no release version fails, before any call of the API."""
+ result = _run(_step(*self.STEP), self._env("v1.2", "true"), bin_dir, repo)
+ assert result.returncode != 0
+ assert not (bin_dir.parent / "calls").exists()
+
+
</code_context>
<issue_to_address>
**Malformed-tag test bypasses regex**
When the regex guard is removed while `v1.2` remains absent from the fixture, `test_no_release_version` still passes because `git cat-file` rejects the nonexistent `v1.2` ref, so its nonzero-status and no-API-call assertions do not show that the regex rejects malformed tags.
Create an existing tag with a malformed release name in the fixture and pass that tag to this test.
</issue_to_address>Sourcery assessment
Approval pending. 6 findings to address first.
Blocking findings: .github/workflows/release.yml:93, .github/workflows/release.yml:474, .github/workflows/release.yml:449, .github/workflows/release.yml:161, .github/workflows/release.yml:127, and 1 more
The signed tag object must carry the pushed tag's name, and a Docker Hub response without a list of tags fails the version check. The malformed-tag test now uses an existing tag. From Sourcery's review. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes #818
The release workflow (
release.yml) gets the two checks that proTES has and FOCA lacked:prepare, "Check release tag and commit"): the tag must be annotated and have a signature that GitHub verified (copied from proTES). The regex check now runs first, so a malformed tag fails before any API call. Errors are now::error::annotations.prepare, new step "Check that the version is not released yet"): fails before anything is built if the version is already on PyPI (/pypi/foca/<version>/jsonis 200) or has an image tagX.Y.ZorX.Y.Z-pyVon Docker Hub (Hub API v2, namespace fromDOCKERHUB_ORGas elsewhere; a missing repository, e.g., in a fork, counts as no tags). Failed lookups fail the step. This catches mistaken tags and "Re-run all jobs" after a partial release; "Re-run failed jobs" doesn't re-runprepare.release-image, new step "Check image tags", before attest/sign/tag):X.Y.Z-pyV(andX.Y.Zfor the default Python) must not exist or already point to this run's digest (re-run of failed jobs). Only the registry's exactERROR: <tag>: not foundcounts as missing; any other error fails the step.latestis meant to move and isn't checked.Docs: "Versioning and releases" in
docs/contributing/index.md(signing keys, the new checks, re-runs) and the workflow's header comment.Decisions taken
check-releaseaction in elixir-cloud-aai/.github covers the signed-tag check, but it isn't in a release yet (latest.githubrelease v1.2.0 has none), and ci: share the release tag checks .github#82 says it is adopted "after the next .github release". So the check is inline, as in proTES, with a comment pointing to Connexion-compatible token validation #82. The shared action does pass against FOCA's realv0.22.0(ran itscheck.pylocally), so the switch should be simple later.Verification
tests/test_release_workflow.pyruns the three step scripts as GitHub runs them (bash --noprofile --norc -eo pipefail), with stand-ins forgh,curlanddocker, in a temporary Git repo with annotated and lightweight tags. It failed before the change (25 of 26) and passes after it (31 tests now).v0.22.0(signed): passes. Version check:0.22.0fails (PyPI; with another package name it fails on the 6 Docker Hub tags),0.23.0and0.22.0rc1pass. Image tag check (buildx 0.26.1):0.22.0with another digest fails, with its real digest passes,9.9.9(not found) passes.ruff check,ruff format --check,mypy,ast-grep scan,semgrep scan --config .semgrep --error,mkdocs build --strict,actionlint(with shellcheck) onrelease.yml: all pass.pyteston the release-related test modules: all pass. I didn't run the full suite locally because it needs MongoDB; CI runs it.Declined review findings
Two rounds of review (adversarial and quality) found nothing high. The mediums and lows were fixed: an exact match of the registry's "not found" line, a test for the branch check, docs on signing keys, and cleaner test helpers. These were declined:
preparepasses for them (low). The org's image repositories are public, andrelease-imagestill blocks moving tags. The comment and the docs name the gap. I didn't add another check inpush.pypistill fails on reused file names.release-image(medium). The logged-in registry lookup also sees private repositories. The match is the exact line, checked against buildx 0.26.1. If buildx rewords it, the step fails closed ("Could not look up …"); it never skips the check.Open questions
None.
🤖 Generated with Claude Code