Skip to content

ci: align release jobs, absolute README images - #588

Merged
uniqueg merged 5 commits into
devfrom
ci/release-align
Nov 1, 2026
Merged

uniqueg merged 5 commits into
devfrom
ci/release-align

Conversation

@uniqueg

@uniqueg uniqueg commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Align the release job IDs and names with cloud-registry and proTES: build becomes prepare ("Prepare release"), the PyPI job is named "Release package" (ID pypi), publish-image becomes release-image ("Release image (Python X)"); push, scan and publish keep their IDs and names. All needs: and needs.<job>.outputs references follow. Environment, permissions, attestations, signing and trusted publishing are unchanged.
  • Before building, the release workflow rewrites relative image paths of README.md to https://raw.githubusercontent.com/${{ github.repository }}/<tag>/<path> (scripts/readme_images.py, stdlib only; handles Markdown, reference-style and HTML <img>/<source> images incl. srcset), then runs check. Tests include the real README.
  • SETUPTOOLS_SCM_PRETEND_VERSION is set for the build: the rewritten README makes the work tree dirty, which I verified makes setuptools-scm produce 0.19.2.dev0+... instead of the release version (the existing version check would have failed the release).
  • Docs: "Versioning and releases" in docs/contributing/index.md names the new jobs and the README rewrite.

Closes #572
Closes #573

Verification

  • ruff check, ruff format --check, actionlint .github/workflows/release.yml: clean. mypy clean for the new files (the rest of the repo needs the full dev install, not run).
  • pytest tests/test_readme_images.py tests/test_repository.py tests/test_version_mentions.py tests/test_docs_hooks.py tests/test_release_assets.py tests/test_citation.py tests/test_release_notes.py --noconftest: passed (full suite with MongoDB not run locally; CI does).
  • Dry run of the build steps locally on a copy with a test tag: rewrite + check, python -m build (with and without the pinned version), twine check --strict passed; the sdist PKG-INFO has the absolute logo URLs.
  • Fork dry run: not possible, uniqueg/foca does not exist. The workflow was only linted (actionlint), not run end to end.
  • CI: pending.

Review

Regular lane (release workflow): adversarial and quality review, two rounds. Fixed: hardening of the rewrite (unquoted attributes, data-src, srcset edge cases, > in attributes, reference-style and shortcut images, angle-bracket paths, leading slash, non-UTF-8), step comment and re-wrapping.

Declined review findings

  • Run the rewrite in ci.yml (dry run): the unit test over the real README covers the rewrite; running it in the CI build job would dirty the tree there as well.
  • Nested brackets in alt text, multi-line images, definitions with the path on the next line, HTML comments and code fences are not handled specially (documented limits of a regex-based rewrite; the README has none of these).
  • Percent-encoding of spaces in angle-bracket paths: not needed for the current README.
  • Splitting the commit in two: both issues change the same workflow file; squash-merged anyway.

Open questions

None. Note for the maintainer: only images are rewritten, relative links (e.g. docs/...md) in the README still do not resolve on PyPI.

🤖 Generated with Claude Code

Summary by Sourcery

Align the release workflow and ensure packaged README images resolve correctly on PyPI.

New Features:

  • Rewrite relative README image paths to release-tagged absolute URLs so package documentation renders correctly on PyPI.

Bug Fixes:

  • Prevent README rewriting from changing the version inferred by setuptools-scm during release builds.

Enhancements:

  • Align release workflow job IDs, names, dependencies, and documentation with the release process terminology.

Documentation:

  • Document the updated release jobs and README image URL rewriting.

Tests:

  • Add coverage for Markdown, reference-style, HTML, and srcset image rewriting, including the repository README.

uniqueg and others added 3 commits November 1, 2026 18:00
Rename the release jobs as in cloud-registry and proTES: build to
prepare ("Prepare release"), the PyPI job to "Release package", and
publish-image to release-image ("Release image"); needs and outputs
follow. Rewrite the relative image paths of the README to URLs pinned
to the release tag before building, as PyPI cannot resolve them
(scripts/readme_images.py, with tests). The rewrite makes the work
tree dirty, so the build pins the version from the tag.

Closes #572
Closes #573

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Handle unquoted attributes, data-src, commas in srcset URLs, paths in
angle brackets and reference-style images (through their
definitions); rename the PyPI upload step; re-wrap comments.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Find images in quoted attributes with a ">", srcset candidates
without a space after the comma, and shortcut reference images; refuse
paths with a leading slash; report non-UTF-8 READMEs as errors.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@uniqueg uniqueg added this to the v0.20.0 milestone Nov 1, 2026
@sourcery-ai

sourcery-ai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR aligns release workflow naming and dependency wiring with related workflows, and adds a tested pre-build README image rewrite that uses release-tagged raw GitHub URLs while pinning the build version to keep setuptools-scm release versions stable.

Sequence diagram for release preparation and artifact publishing

sequenceDiagram
    participant GitHub
    participant Prepare as prepare: Prepare release
    participant Push as push: Push release image
    participant Scan as scan: Scan release image
    participant PyPI as pypi: Release package
    participant ReleaseImage as release-image: Release image
    participant Publish as publish: Publish release
    GitHub->>Prepare: Trigger on version tag
    Prepare->>Prepare: rewrite
    Prepare->>Prepare: check
    Prepare->>Prepare: python -m build
    Prepare->>Push: needs.prepare.outputs.version
    Push->>Scan: Image digests
    Prepare->>PyPI: Distributions
    Scan->>PyPI: Scan passed
    Prepare->>ReleaseImage: needs.prepare.outputs.version
    Scan->>ReleaseImage: Scanned digests
    PyPI->>ReleaseImage: Package released
    Prepare->>Publish: Release metadata
    PyPI->>Publish: Package dependency
    ReleaseImage->>Publish: Tagged images
Loading

Flow diagram for rewriting README image paths before release build

flowchart LR
    A[README.md with relative image paths] --> B[rewrite]
    B --> C[Release-tagged raw GitHub URLs]
    C --> D[check]
    D --> E[python -m build]
    E --> F[Package long description with resolvable images]
    E --> G[SETUPTOOLS_SCM_PRETEND_VERSION]
    G --> H[Release version remains stable]
Loading

File-Level Changes

Change Details Files
Rename and realign release workflow jobs and dependency references without changing release security or publishing behavior.
  • Rename build to prepare and update its display name and outputs consumers.
  • Rename the PyPI display/action step and publish-image to release-image, updating all needs and output references.
  • Preserve environments, permissions, attestations, signing, trusted publishing, and release ordering.
.github/workflows/release.yml
docs/contributing/index.md
Rewrite README image references to release-tagged absolute URLs before distribution builds so packaged descriptions render correctly on PyPI.
  • Add a stdlib-only CLI supporting Markdown, reference-style, HTML src/srcset, URL filtering, normalization, and validation.
  • Run rewrite and validation in the prepare job using repository and tag context.
  • Pin SETUPTOOLS_SCM_PRETEND_VERSION during the build to prevent the intentional README modification from producing a development version.
scripts/readme_images.py
.github/workflows/release.yml
Add focused coverage for image rewriting, error handling, and repository integration.
  • Test Markdown, reference-style, HTML, unquoted attributes, srcset, angle-bracket paths, absolute URLs, and invalid paths.
  • Verify the real README rewrites cleanly and CLI check/rewrite behavior handles missing and non-UTF-8 files.
tests/test_readme_images.py
Update contributor documentation to describe the renamed release jobs, approval sequence, and README image handling.
  • Document the prepare, pypi, and release-image job IDs and names.
  • Explain release-tag-pinned absolute README image URLs and the unchanged three-approval flow.
docs/contributing/index.md

Possibly linked issues


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

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##               dev      #588   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           56        56           
  Lines         7068      7068           
=========================================
  Hits          7068      7068           
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 1, 2026 17:22
Collapse whitespace and fold case when matching reference-style
images with their definitions, as CommonMark does.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

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

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

## Individual Comments

### Comment 1
<location path="scripts/readme_images.py" line_range="37" />
<code_context>
+# Paths with a scheme (`https:`, `data:`), `//host/...` and `#fragment`
+_ABSOLUTE = re.compile(r"^(?:[A-Za-z][A-Za-z0-9+.\-]*:|//|#)")
+# `![alt](path "title")` or `![alt](<path>)`; the path is group 3
+_MARKDOWN_IMAGE = re.compile(r"(!\[[^\]]*\]\(\s*)(<?)(?:(?<=<)([^>]+)|([^)\s>]+))")
+# `![alt][ref]` (or `![ref][]`), whose path is in a definition (`[ref]: path`);
+# the label is group 1 or 2
</code_context>
<issue_to_address>
**Image paths are truncated**

When an unbracketed Markdown image destination contains balanced parentheses, `_MARKDOWN_IMAGE` stops at the first `)`, so `rewrite` changes only a prefix and `check` can pass on that prefix. The resulting image URL is truncated, and traversal segments after the parentheses can escape the release-tag path.

Parse the full balanced-parenthesis destination before rewriting or checking the image path.
</issue_to_address>

### Comment 2
<location path="scripts/readme_images.py" line_range="166" />
<code_context>
+
+    # Labels of reference-style images, normalized as in CommonMark
+    labels = {
+        (ref or alt).strip().lower() for alt, ref in _REFERENCE_IMAGE.findall(text)
+    }
+    text = _DEFINITION.sub(definition, text)
</code_context>
<issue_to_address>
**Reference images stay broken**

When a valid reference-style image and its definition use labels that differ only in repeated internal whitespace or tabs, the label set uses `strip().lower()` without collapsing internal whitespace, so `rewrite` and `check` fail to match the definition. The relative URL remains in the package README, `check` passes, and the image does not render on PyPI.

Collapse internal whitespace in reference labels according to CommonMark before comparing them.
</issue_to_address>

### Comment 3
<location path="scripts/readme_images.py" line_range="53" />
<code_context>
+# `src="..."`, `srcset='...'` or `src=a.png` (not `data-src`); the value is
+# group 3, 4 or 5
+_HTML_ATTRIBUTE = re.compile(
+    r"""((?<![\w-])(src|srcset)\s*=\s*)(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))""",
+    re.IGNORECASE,
+)
</code_context>
<issue_to_address>
**Alt text gets rewritten**

When a quoted HTML attribute value contains text resembling `src=` or `srcset=` followed by a relative path, `_HTML_ATTRIBUTE.sub` scans the whole tag without tracking quoted attribute values, so `rewrite` treats that text as an actual image attribute and changes displayed or accessible text in the packaged README.

Parse HTML tag attributes while respecting quoted value boundaries before rewriting image sources.
</issue_to_address>

Linked issues

#572 ci: align the release job names · 3 of 4 met

# Requirement Status Notes
1 Add a prepare job named “Prepare release” and make the other jobs depend on it. ✅ Met The release jobs use prepare directly or depend on it through push.
2 Ensure CI passed for the tagged commit. ❌ Not addressed The prepare job checks the tag, branch ancestry, citation metadata, and release notes, but does not check CI status for the tagged commit.
3 Name registry-publishing jobs after what they release, with names unique across workflows. ✅ Met The jobs are named “Release package,” “Push release image,” and “Release image,” distinct from the corresponding CI job names.
4 Use publish / “Publish release” to create the GitHub release. ✅ Met The publish job retains that name and creates the release after the package and images are released.

#573 ci: rewrite README image paths for PyPI · 3 of 3 met

# Requirement Status Notes
1 Before building, rewrite relative README image paths to absolute raw GitHub URLs pinned to the release tag. ✅ Met The prepare job passes the repository and tag to the rewrite command, then runs check before python -m build.
2 Test that the rewritten README has no relative image paths left. ✅ Met The test rewrites the repository README and asserts that relative_paths returns no paths.
3 Keep the build backend as setuptools with setuptools-scm. ✅ Met The change does not alter the build backend.

Sourcery assessment

Needs a human reviewer. 3 findings to address first, and if the README rewrite or release-job wiring is wrong, the workflow could publish a package whose long description has incorrect image URLs. Reverting stops future runs but cannot replace the already-published immutable PyPI version.

Blocking findings: scripts/readme_images.py:37, scripts/readme_images.py:166, scripts/readme_images.py:53


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

Comment thread scripts/readme_images.py Resolved
Comment thread scripts/readme_images.py Resolved
Comment thread scripts/readme_images.py Resolved

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

Linked issues

#572 ci: align the release job names · 3 of 4 met

# Requirement Status Notes
1 The prepare stage checks the tag, version, citation metadata, and that CI passed for the commit. 🟡 Partly met The workflow checks the tag/version, citation metadata, and release notes, but does not check whether CI passed for the tagged commit.
2 Use a prepare job named “Prepare release,” with the other jobs depending on it. ✅ Met The downstream jobs depend on prepare directly or through push.
3 Name registry-publishing jobs after what they release, with names unique across the repository’s workflows. ✅ Met The package, image-push, scan, and image-release job names follow the requested naming pattern.
4 Keep publish / “Publish release” for creating the GitHub release. ✅ Met

#573 ci: rewrite README image paths for PyPI · 3 of 3 met

# Requirement Status Notes
1 Before building, rewrite relative README image paths to absolute URLs pinned to the release tag, using the repository from the run context. ✅ Met The workflow runs the rewrite and check before the build, passing github.repository and github.ref_name.
2 Test that the rewritten README has no relative image paths left. ✅ Met The real-README test asserts that relative_paths finds none after rewriting.
3 Keep the build backend as setuptools with setuptools-scm. ✅ Met The change does not alter the build backend configuration.

Comment thread .github/workflows/release.yml Resolved
@uniqueg
uniqueg merged commit f68171e into dev Nov 1, 2026
56 checks passed
@uniqueg
uniqueg deleted the ci/release-align branch November 1, 2026 19:05
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: rewrite README image paths for PyPI ci: align the release job names

1 participant