Skip to content

ci: check tag signature and released versions - #819

Merged
uniqueg merged 4 commits into
devfrom
ci/release-tag-checks
Nov 22, 2026
Merged

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

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #818

The release workflow (release.yml) gets the two checks that proTES has and FOCA lacked:

  • Signed tag (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.
  • Version not released yet (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>/json is 200) or has an image tag X.Y.Z or X.Y.Z-pyV on Docker Hub (Hub API v2, namespace from DOCKERHUB_ORG as 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-run prepare.
  • Image tags never move (release-image, new step "Check image tags", before attest/sign/tag): X.Y.Z-pyV (and X.Y.Z for the default Python) must not exist or already point to this run's digest (re-run of failed jobs). Only the registry's exact ERROR: <tag>: not found counts as missing; any other error fails the step. latest is 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

  • The shared check-release action in elixir-cloud-aai/.github covers the signed-tag check, but it isn't in a release yet (latest .github release 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 real v0.22.0 (ran its check.py locally), so the switch should be simple later.
  • The version check is stricter than proTES, which only checks the image tag when the GitHub release is already published. Here any existing version tag on another digest fails, because the image tags of a partly finished release may have been pulled already.

Verification

  • TDD: tests/test_release_workflow.py runs the three step scripts as GitHub runs them (bash --noprofile --norc -eo pipefail), with stand-ins for gh, curl and docker, 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).
  • The step scripts against the real services: tag check on FOCA's v0.22.0 (signed): passes. Version check: 0.22.0 fails (PyPI; with another package name it fails on the 6 Docker Hub tags), 0.23.0 and 0.22.0rc1 pass. Image tag check (buildx 0.26.1): 0.22.0 with 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) on release.yml: all pass. pytest on the release-related test modules: all pass. I didn't run the full suite locally because it needs MongoDB; CI runs it.
  • Not run: a fork dry run of the release workflow (the checks were run as scripts against the real services instead).
  • CI: all checks passed on 536fdd4 (CI passed, Sourcery review). Sourcery: 6 threads; 3 fixed (tag object name must match the tag, Docker Hub response must have a list of tags, malformed-tag test uses an existing tag), 3 answered and declined (races with a second publisher: releases are serialised and only admins publish). All resolved.

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:

  • The Docker Hub API answers 404 for private repositories, so prepare passes for them (low). The org's image repositories are public, and release-image still blocks moving tags. The comment and the docs name the gap. I didn't add another check in push.
  • Versions deleted from PyPI aren't detected (low). The public JSON API can't see them. The comment names the gap, and pypi still fails on reused file names.
  • Use the Docker Hub API instead of matching buildx's error text in 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

uniqueg and others added 3 commits November 22, 2026 14:52
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]>
@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

Require 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.

  • .github/workflows/release.yml L70-104, L121-179, L448-482 (+1 small edits)

Documentation

Document the signing-key requirements, registry checks, and safe rerun behavior for releases.

  • docs/contributing/index.md L286-300, L354-358

Tests

Add tests for release-tag validation, version availability lookups, image-tag immutability, lookup failures, and check ordering.

  • tests/test_release_workflow.py L1-517

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

@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 (f003a36) to head (536fdd4).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #819   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           76        76           
  Lines        10708     10708           
=========================================
  Hits         10708     10708           
Flag Coverage Δ
test_unit 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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 19:17
@sourcery-ai

sourcery-ai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 536fdd4

#818 ci: check tag signature and existing release versions · 4 of 4 met

# Requirement Status Notes
1 prepare fails unless the tag is annotated and has a signature that GitHub verified ✅ Met The tag check rejects lightweight tags and checks GitHub’s verification result before producing the version output.
2 prepare fails if the version is already on PyPI or one of its image tags exists on Docker Hub ✅ Met The new check runs before distributions are built, rejects existing PyPI versions and matching Docker Hub tags, and fails on unsuccessful or incomplete lookups.
3 release-image fails before attesting, signing or tagging if an image tag already points to another digest ✅ Met The image-tag check compares the version tags against this run’s digest and runs before attestation, signing and tagging.
4 Add workflow tests and update the release documentation ✅ Met Adds tests for the release checks and updates the release guidance on signing, registry checks and reruns.

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


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 tests/test_release_workflow.py Resolved
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]>
@uniqueg
uniqueg merged commit 515b2fd into dev Nov 22, 2026
83 checks passed
@uniqueg
uniqueg deleted the ci/release-tag-checks branch November 22, 2026 19:45
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: check tag signature and existing release versions

1 participant