Skip to content

ci: add release and scheduled scan workflows - #66

Merged
uniqueg merged 5 commits into
devfrom
ci/release-scan
Nov 7, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/release-scan

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

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 (from v* tags): prepare checks the tag (release version, annotated, signature verified by GitHub, commit on main), the versions (scripts/check_versions.py: __version__ in pubgrade/__init__.py, the chart's version and appVersion), 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). push builds both images and pushes them by digest only (environment release). scan scans 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 (environment release) checks the chart against its recorded name and SHA-256, attests and signs both digests, tags them X.Y.Z (and latest for 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 of latest of both images, uploaded to code scanning with a report artifact. Doesn't fail until the first release: latest is still an image from January 2025 on FOCA 0.7; the comment and docs say to drop fail: "false" for pubgrade then.
  • Scripts (scripts/, standard library only): release_version.py, citation.py, release_assets.py and release_notes.py as in Pubgrade-Sidecar (ported from cloud-registry), and check_versions.py adapted to Pubgrade (it parses __version__ with ast and accepts only a single top-level assignment of a string literal; from a Sourcery review). Tested in tests/scripts/, with the app's coverage (setup.cfg). .gitignore ignored every scripts directory (virtualenv template); /scripts/ and /tests/scripts/ are exempt now.
  • Docs: "Versioning and releases" in docs/development.md (release-prep, tagging, what the workflow checks and does, verifying a released image, scans); image tags of released charts in docs/deployment.md; a comment on the one version in helm/Chart.yaml.

Closes #50

Verification

  • make test (Python 3.13): 403 passed, 100% coverage (scripts included).
  • actionlint 1.7.7 (with shellcheck) on all workflows: no findings.
  • The "Package chart" step replayed locally (Helm 3.22.1, yq): the packaged pubgrade-0.2.0.tgz lints strictly and has elixircloud/pubgrade:0.2.0 and elixircloud/pubgrade-updater:0.2.0 as images; nothing else in values.yaml changes (yq drops blank lines).
  • Scripts against the current tree: release_version.py outputs v0.2.0 gives 0.2.0 / 0.2.0, pre-release; check_versions.py and citation.py check fail as expected until the release-prep pull request sets the versions and CITATION.cff; latest and previous give true and no previous tag for a first v0.2.0.
  • helm lint helm --strict, tests/chart.sh and mkdocs build --strict: OK.
  • CI: all checks passed (PR title, Lint, Test, Chart, Docs, Smoke test, Upgrade test, Scan image, CodeQL including Actions, Codecov, Read the Docs), CI passed.

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)

  1. Fork to a personal account; set the variable DOCKERHUB_ORG to a test organization and create the environment release with DOCKERHUB_LOGIN and DOCKERHUB_TOKEN for it (and a required reviewer, to exercise the approvals).
  2. On a branch, do the release-prep (pubgrade/__init__.py, helm/Chart.yaml to e.g. 0.0.1rc1/0.0.1-rc1, python scripts/citation.py set 0.0.1rc1), push it to dev of the fork so that CI runs for a push and passes, then fast-forward main to it.
  3. Tag git tag -s v0.0.1rc1 -m v0.0.1rc1 on main and push the tag; approve push and publish.
  4. Check: both images in the test organization tagged 0.0.1rc1 (not latest, as a pre-release), signed (cosign verify with the fork's release.yml@refs/tags/v0.0.1rc1 identity) 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.1rc1 and <test org>/pubgrade-updater:0.0.1rc1; the notes list the merged pull requests (first release).
  5. Negative checks: an unsigned or lightweight tag, a tag of a commit not on main, and mismatched versions each fail in prepare before anything is pushed. Run Scan by hand to see both matrix jobs report.
  6. Delete the fork's test tags, release and images afterwards.

Review

Full review (adversarial-reviewer and quality-reviewer), one round: no high or medium findings. Fixed lows: the chart's values no longer say that the image of a released chart follows dev; reflowed and clarified comments; a test named for what it checks; a note to keep the images of push, scan and publish in sync.

Declined review findings

  • The release scripts are copies in cloud-registry, Pubgrade-Sidecar and Pubgrade (low): as issue ci: add release and scheduled scan workflows #50 asks for the same structure; a shared action would be a change of its own.
  • Separate steps per image instead of a matrix in push and publish (low): a matrix would split the digests across jobs; the two images are spelled out as in CI.
  • yq drops blank lines in the packaged values.yaml (low): cosmetic; comments stay.

Before the first tag, the maintainer should confirm what the review couldn't read here: the environment release exists with a required reviewer (otherwise GitHub creates it unprotected on the first run), the tag ruleset for v* tags exists, and the release commit reaches main by fast-forward (a merge or rebase merge gives a commit without a CI push run, and prepare fails). Immutable releases are on.

Open questions

None.

🤖 Generated with Claude Code

uniqueg and others added 4 commits November 6, 2026 19:29
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]>
@sourcery-ai

sourcery-ai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Add standard-library utilities for release-version selection, app and chart version validation, citation metadata, release assets, and first-release notes.

  • scripts/check_versions.py L1-143
  • scripts/citation.py L1-290
  • scripts/release_assets.py L1-246
  • scripts/release_notes.py L1-233
  • scripts/release_version.py L1-250

Configuration

Configure tag-driven release publishing and weekly scans, and align chart metadata and defaults with versioned releases.

  • .github/workflows/release.yml L1-532
  • .github/workflows/scan.yml L1-55
  • helm/Chart.yaml L5-10
  • helm/values.yaml L21-23, L29-31

Include the release scripts and their tests in coverage, and exempt their directories from the virtualenv ignore rules.

  • .gitignore L186-188
  • setup.cfg L5-11

Documentation

Explain release preparation and verification, image signing and scanning, and the tags and images used by release charts.

  • docs/deployment.md L34-37
  • docs/development.md L57-58, L104-172

Tests

Test release-version parsing and selection, app and chart version checks, citation updates, asset integrity, and first-release notes.

  • tests/scripts/test_check_versions.py L1-119
  • tests/scripts/test_citation.py L1-299
  • tests/scripts/test_release_assets.py L1-321
  • tests/scripts/test_release_notes.py L1-191
  • tests/scripts/test_release_version.py L1-422

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 6, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 Pubgrade | 🛠️ Build #35713059 | 📁 Comparing c574138 against latest (f7d74eb)

  🔍 Preview build  

2 files changed
± deployment/index.html
± development/index.html

@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 (f7d74eb) to head (c574138).

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.
📢 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 19:06
@uniqueg
uniqueg requested a review from akash2237778 as a code owner November 6, 2026 19:06

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


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 scripts/release_assets.py Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread scripts/check_versions.py Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread .github/workflows/release.yml Resolved
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]>
@uniqueg
uniqueg merged commit e04a025 into dev Nov 7, 2026
40 of 43 checks passed
@uniqueg
uniqueg deleted the ci/release-scan branch November 7, 2026 03:33
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: add release and scheduled scan workflows

1 participant