Repository navigation
ci: add release and scheduled scan workflows - #66
Conversation
Add the release scripts of cloud-registry, as ported to Pubgrade-Sidecar (release versions, citation metadata, release assets, notes of a first release), and check_versions.py for one version of the app (`__version__`) and the chart. Test them in tests/scripts/, with the app's coverage, and keep the directories out of the virtualenv ignores. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Release from signed version tags on main as cloud-registry and Pubgrade-Sidecar do: check the tag, versions, citation metadata and CI, package the chart with the images of the release as defaults, push both images by digest, scan them (the updater's image is reported only, as in CI), then attest, sign and tag the images, and create the release with the signed chart. Scan `latest` of both images weekly, without failing until the first release has published it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Describe the release steps, what the release workflow checks and does, how to verify a released image, the scans, and the image tags of released charts. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Say in the chart's values that a released chart uses the images of its release, reflow and clarify comments of the release workflow and the version check, and name the repository test for what it checks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideImplementationAdd standard-library utilities for release-version selection, app and chart version validation, citation metadata, release assets, and first-release notes.
ConfigurationConfigure tag-driven release publishing and weekly scans, and align chart metadata and defaults with versioned releases.
Include the release scripts and their tests in coverage, and exempt their directories from the virtualenv ignore rules.
DocumentationExplain release preparation and verification, image signing and scanning, and the tags and images used by release charts.
TestsTest release-version parsing and selection, app and chart version checks, citation updates, asset integrity, and first-release notes.
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 #66 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 10 15 +5
Lines 752 1135 +383
==========================================
+ Hits 752 1135 +383 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 9 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="34" />
<code_context>
+
+on:
+ push:
+ tags: ["v*"]
+
+permissions:
</code_context>
<issue_to_address>
**Tags can select privileged workflow code**
When the tag ruleset permits an untrusted writer to create a `v*` tag pointing to a commit with a modified workflow file, gitHub runs the workflow definition from the tagged commit, so a writer who can tag a commit containing a modified `release.yml` can replace or remove the `prepare` checks and define privileged jobs that access release secrets and signing permissions after environment approval.
Ensure only authorized release actors can create version tags and have privileged release jobs run from a trusted, protected workflow definition rather than one supplied by the tag.
</issue_to_address>
### Comment 2
<location path=".github/workflows/release.yml" line_range="243" />
<code_context>
+ uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
+ with:
+ context: .
+ file: build-complete-updater/Dockerfile
+ outputs: type=image,name=${{ env.IMAGE_PREFIX }}/pubgrade-updater,push-by-digest=true,name-canonical=true,push=true
+ sbom: true
</code_context>
<issue_to_address>
**Unpinned updater base enters releases**
When the upstream `python:3` tag changes to compromised content after CI has tested the release commit, the updater build resolves `FROM python:3` afresh, so the release job can sign and tag an image containing upstream code that was not present in the successful CI build; the updater can read pod `ACCESSTOKEN` values and send them in requests, exposing those credentials if the upstream image is compromised.
Pin the updater base image by digest and ensure the released build uses the same dependency inputs that CI tested.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release.yml" line_range="101" />
<code_context>
+ 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>
**Untrusted signers can trigger releases**
When a writer allowed to create `v*` tags signs a version-matching tag for a commit on `main` with a key GitHub recognizes, but the project has not authorized that signer, `prepare` checks only `.verification.verified`, not whether the signing key belongs to an authorized releaser, so a GitHub-recognized but unauthorized signer passes the check and can reach the protected image-publishing and release jobs once approved.
Restrict tag creation to authorized release actors and verify the tag signature against an explicit trusted signer policy before publishing.
</issue_to_address>
### Comment 4
<location path="scripts/release_assets.py" line_range="113" />
<code_context>
+ if path.name not in uploaded:
+ missing.append(path.name)
+ elif uploaded[path.name] != sha256(path):
+ signature = path.name.endswith(SIGNATURE_SUFFIX)
+ (resigned if signature else changed).append(path.name)
+ names = {path.name for path in paths}
</code_context>
<issue_to_address>
**Invalid chart signatures are retained**
When a writer pre-publishes the tag's release with the expected chart and a forged or wrong-identity `.sigstore.json` bundle, `check_published` treats every changed `.sigstore.json` as merely `resigned`, so `release_state` still returns `published`; the workflow skips uploading its newly generated bundle and finalizes a release carrying an invalid or unauthorized chart signature.
Verify an existing chart bundle against the chart and the expected release-workflow identity before accepting a published release.
</issue_to_address>
### Comment 5
<location path=".github/workflows/release.yml" line_range="413-425" />
<code_context>
+ | python scripts/release_version.py latest "${TAG}" >> "${GITHUB_OUTPUT}"
+ # Tags `X.Y.Z` (and `latest`) point to the checked, scanned and signed
+ # digests: a single source is copied as is
+ - name: Tag images
+ env:
+ LATEST: ${{ steps.latest.outputs.latest }}
+ run: |
+ for image in "pubgrade@${DIGEST_PUBGRADE}" "pubgrade-updater@${DIGEST_UPDATER}"; do
+ name="${IMAGE_PREFIX}/${image%@*}"
+ digest="${image#*@}"
+ tags=("${name}:${VERSION}")
+ if [[ "${LATEST}" == "true" ]]; then
+ tags+=("${name}:latest")
+ fi
+ for tag in "${tags[@]}"; do
+ docker buildx imagetools create --tag "${tag}" "${name}@${digest}"
+ actual="$(docker buildx imagetools inspect "${tag}" \
+ --format '{{ json .Manifest }}' | jq -r .digest)"
</code_context>
<issue_to_address>
**Images point to different releases**
When tagging or inspecting the second image fails after the first image's tags have been updated, the tag loop updates the images sequentially and exits without undoing the first update, so `pubgrade` and `pubgrade-updater` point to different releases and consumers get mismatched images.
Make a failed tag update restore the earlier image tags so both images remain on the same release.
</issue_to_address>
### Comment 6
<location path=".github/workflows/release.yml" line_range="51" />
<code_context>
+# One run per tag, so that a run waiting for approval is not cancelled by
+# the run of another tag; `latest` is decided at the end of each run, from
+# freshly fetched tags on `main`
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: false
</code_context>
<issue_to_address>
**Older release takes over latest**
When release runs for different tags overlap and the older run checks the highest tag before the newer tag is visible, the per-tag concurrency group lets both runs proceed, and `steps.latest.outputs.latest` stays true after its check; the older run's `Tag images` step then overwrites the newer image's `latest` tags, and `gh release edit` can mark the older release latest. Users see the older release as latest.
Serialize latest promotion across release tags and recheck which release is highest immediately before promoting the image tags and GitHub release.
Also at `.github/workflows/release.yml:52-53`, `.github/workflows/release.yml:400-425`, `.github/workflows/release.yml:524`, `.github/workflows/release.yml:532`.
</issue_to_address>
### Comment 7
<location path="scripts/check_versions.py" line_range="30" />
<code_context>
+
+# `__version__ = "..."` (or with single quotes) at the start of a line
+APP_VERSION = re.compile(
+ r"^__version__[ \t]*=[ \t]*(?P<quote>[\"'])(?P<value>[^\"'\n]*)(?P=quote)",
+ re.M,
+)
</code_context>
<issue_to_address>
**Release accepts the wrong version**
When `pubgrade/__init__.py` contains a version assignment with a trailing expression or multiple top-level `__version__` assignments, `APP_VERSION.search` captures a quoted prefix or the first assignment instead of the effective value used when `pubgrade` is imported; `check_versions.py` therefore passes while the released app reports a different version from its tag.
Parse and validate the effective `__version__` value, rejecting assignments whose full expression cannot be checked.
Also at `scripts/check_versions.py:61-62`.
</issue_to_address>
### Comment 8
<location path=".github/workflows/release.yml" line_range="460" />
<code_context>
+ run: |
+ set -o pipefail
+ published="$(mktemp)"
+ gh release list --limit 1000 --exclude-drafts --json tagName \
+ --jq '.[].tagName' > "${published}"
+ git tag -l 'v*' --merged HEAD \
</code_context>
<issue_to_address>
**Release notes use the wrong range**
When the semantically closest prior published release is outside the 1,000 releases returned by `gh release list`, `release_version.py previous` receives no tag for that release and selects an older baseline or none, so the generated notes include changes from the wrong range.
Determine the previous published release without limiting the candidate tags to the first 1,000 results.
</issue_to_address>
### Comment 9
<location path=".github/workflows/release.yml" line_range="460-464" />
<code_context>
+ run: |
+ set -o pipefail
+ published="$(mktemp)"
+ gh release list --limit 1000 --exclude-drafts --json tagName \
+ --jq '.[].tagName' > "${published}"
+ git tag -l 'v*' --merged HEAD \
+ | python scripts/release_version.py previous "${TAG}" \
+ --published "${published}" >> "${GITHUB_OUTPUT}"
+ # Assets of a published immutable release (a repository setting) can't
+ # be added, replaced or deleted, so the release is created as a draft,
</code_context>
<issue_to_address>
**Release notes repeat earlier changes**
When a newer release determines its previous release while an earlier release in its history is still a draft or unpublished, `previous_tag` excludes the earlier release, so the newer release selects an older predecessor and its generated notes repeat changes already covered by that release.
Account for earlier in-progress release tags when selecting the previous release for notes.
Also at `.github/workflows/release.yml:490-493`.
</issue_to_address>Linked issues
#50 ci: add release and scheduled scan workflows · 3 of 3 met
| # | Requirement | Status | Notes |
|---|---|---|---|
| 1 | Release from v* tags in the release environment: push, scan, sign and tag images, then create a draft GitHub release. |
✅ Met | Implemented in .github/workflows/release.yml with prepare, push, scan, and publish jobs. |
| 2 | Scan latest weekly. |
✅ Met | .github/workflows/scan.yml schedules scans of both images’ latest tags. |
| 3 | Both workflows exist with the names and structure of cloud-registry's. | ✅ Met | The workflows are named Release and Scan and provide the described release and scheduled-scan flows. |
Sourcery assessment
Needs a human reviewer. 9 findings to address first, and if the release checks or image-handling steps are wrong, an unintended image could be signed and assigned a version or latest tag, and a chart could be attached to a published release. Reverting the workflow stops future runs, but does not undo artifacts consumers may already have pulled or change the assets of an immutable release.
Blocking findings: .github/workflows/release.yml:34, .github/workflows/release.yml:243, .github/workflows/release.yml:101, scripts/release_assets.py:113, .github/workflows/release.yml:425, and 4 more
check_versions.py read the first top-level line matching __version__ = "...", so a second assignment or a trailing expression could make it pass with a version the app does not report. It now parses pubgrade/__init__.py and accepts only a single top-level assignment of a string literal. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Adds the release workflow and a weekly scan of released images, as cloud-registry and Pubgrade-Sidecar have them, verify-first: nothing is signed, tagged or released before the tag, the versions, CI and the image scan are checked.
release.yml/Release(fromv*tags):preparechecks the tag (release version, annotated, signature verified by GitHub, commit onmain), the versions (scripts/check_versions.py:__version__inpubgrade/__init__.py, the chart'sversionandappVersion), the citation metadata (scripts/citation.py check) and a successful CI run for a push of the commit, then packages the chart with the images of the release as defaults (<org>/pubgrade:X.Y.Z,<org>/pubgrade-updater:X.Y.Z; rewritten by yq in a copy and checked in the package).pushbuilds both images and pushes them by digest only (environmentrelease).scanscans exactly those digests without credentials; the app's image fails on fixable critical and high findings, the updater's image is reported only, as in CI.publish(environmentrelease) checks the chart against its recorded name and SHA-256, attests and signs both digests, tags themX.Y.Z(andlatestfor the highest stable release), and creates the release as a draft, uploads the chart and its Sigstore bundle, and publishes it (immutable releases). Until 1.0.0, releases are pre-releases.scan.yml/Scan: weekly (and on demand) scan oflatestof both images, uploaded to code scanning with a report artifact. Doesn't fail until the first release:latestis still an image from January 2025 on FOCA 0.7; the comment and docs say to dropfail: "false"forpubgradethen.scripts/, standard library only):release_version.py,citation.py,release_assets.pyandrelease_notes.pyas in Pubgrade-Sidecar (ported from cloud-registry), andcheck_versions.pyadapted to Pubgrade (it parses__version__withastand accepts only a single top-level assignment of a string literal; from a Sourcery review). Tested intests/scripts/, with the app's coverage (setup.cfg)..gitignoreignored everyscriptsdirectory (virtualenv template);/scripts/and/tests/scripts/are exempt now.docs/development.md(release-prep, tagging, what the workflow checks and does, verifying a released image, scans); image tags of released charts indocs/deployment.md; a comment on the one version inhelm/Chart.yaml.Closes #50
Verification
make test(Python 3.13): 403 passed, 100% coverage (scripts included).pubgrade-0.2.0.tgzlints strictly and haselixircloud/pubgrade:0.2.0andelixircloud/pubgrade-updater:0.2.0as images; nothing else invalues.yamlchanges (yq drops blank lines).release_version.py outputs v0.2.0gives0.2.0/0.2.0, pre-release;check_versions.pyandcitation.py checkfail as expected until the release-prep pull request sets the versions andCITATION.cff;latestandpreviousgivetrueand no previous tag for a firstv0.2.0.helm lint helm --strict,tests/chart.shandmkdocs build --strict: OK.Not run here (no tags): the workflow end to end. A dry run in a fork is described below.
Dry run in a fork (before the first release)
DOCKERHUB_ORGto a test organization and create the environmentreleasewithDOCKERHUB_LOGINandDOCKERHUB_TOKENfor it (and a required reviewer, to exercise the approvals).pubgrade/__init__.py,helm/Chart.yamlto e.g.0.0.1rc1/0.0.1-rc1,python scripts/citation.py set 0.0.1rc1), push it todevof the fork so that CI runs for a push and passes, then fast-forwardmainto it.git tag -s v0.0.1rc1 -m v0.0.1rc1onmainand push the tag; approvepushandpublish.0.0.1rc1(notlatest, as a pre-release), signed (cosign verifywith the fork'srelease.yml@refs/tags/v0.0.1rc1identity) and attested; the release is a published pre-release with the chart and its.sigstore.json; the chart's values name<test org>/pubgrade:0.0.1rc1and<test org>/pubgrade-updater:0.0.1rc1; the notes list the merged pull requests (first release).main, and mismatched versions each fail inpreparebefore anything is pushed. RunScanby hand to see both matrix jobs report.Review
Full review (
adversarial-reviewerandquality-reviewer), one round: no high or medium findings. Fixed lows: the chart's values no longer say that the image of a released chart followsdev; reflowed and clarified comments; a test named for what it checks; a note to keep the images ofpush,scanandpublishin sync.Declined review findings
pushandpublish(low): a matrix would split the digests across jobs; the two images are spelled out as in CI.yqdrops blank lines in the packagedvalues.yaml(low): cosmetic; comments stay.Before the first tag, the maintainer should confirm what the review couldn't read here: the environment
releaseexists with a required reviewer (otherwise GitHub creates it unprotected on the first run), the tag ruleset forv*tags exists, and the release commit reachesmainby fast-forward (a merge or rebase merge gives a commit without a CI push run, andpreparefails). Immutable releases are on.Open questions
None.
🤖 Generated with Claude Code