Repository navigation
ci: publish curated release notes - #123
Conversation
The release workflow created releases with GitHub's generated notes only, to be edited by hand into the agreed format after publishing. As in cloud-registry, it now publishes the curated notes of docs/releases/<version>.md followed by the generated ones, and fails before anything is pushed if they contain TODO, aren't in the agreed format, or are missing once any release has curated notes. scripts/release_notes.py is cloud-registry's (commands check, body, require and first), with the docs host and repositories of Pubgrade and Pubgrade-Sidecar for the check of links to versions that move. The tests are cloud-registry's, plus links of both repositories; they also check every file in docs/releases/. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes. The release workflow rejects curated notes with a TODO only after the tag is pushed, which then can't be reused, so the test of the notes in docs/releases/ now rejects them too, and the pre-tag steps in docs/development.md run the same grep (as cloud-registry's do). The docs also give the nav entry of the first notes, say that a re-run replaces the notes of a published release with the curated ones, and the script names cloud-registry's copy as canonical and the constants that differ from it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every job of the release workflow reads the curated notes of the tagged commit, which can't change, so a fix in docs/releases/<version>.md never reaches a published release. Say that the notes must be right before the tag, that published notes are fixed by hand (and in docs/releases/ on dev, for the docs), and that a re-run of publish writes the tagged notes back over hand edits. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideImplementationAdd release-note validation, link checks, missing-note enforcement, generated-body composition, and CLI commands for checking and publishing curated notes.
ConfigurationValidate curated notes before release and publish them with generated notes, while allowing published-release reruns to update notes only when curated notes exist.
DocumentationDocument the curated-notes workflow, required format and links, pre-tag checks, navigation entry, and published-release rerun behavior.
TestsTest release-note validation and link rules, generated-body formatting, required-note behavior, and the notes shipped in the repository.
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 #123 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 18 18
Lines 1545 1748 +203
==========================================
+ Hits 1545 1748 +203 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="scripts/release_notes.py" line_range="781" />
<code_context>
+ return _require(args)
+ notes: Path = args.notes
+ try:
+ curated = notes.read_text(encoding="utf-8")
+ generated = (
+ args.generated.read_text(encoding="utf-8") if args.command == "body" else ""
</code_context>
<issue_to_address>
**Release notes expose workflow token**
When a release commit makes `docs/releases/<version>.md` a symlink to `/proc/self/environ`, `Path.read_text()` follows the symlink, and `check()` accepts the NUL-separated environment as a nonempty intro paragraph; `body()` then writes it into the published release notes, exposing the `contents: write` token.
Reject symlinked notes and verify that the file opened for publication is a regular file within the checked-out repository, without following symlinks.
</issue_to_address>
### Comment 2
<location path="scripts/release_notes.py" line_range="471" />
<code_context>
+ that move (`UNVERSIONED`) and no relative links (`_link_targets`). An
+ HTML comment on a line of its own counts as a blank line.
+ """
+ lines = markdown.removeprefix("\ufeff").splitlines()
+ findings = _Checker().run(lines)
+ findings += [
</code_context>
<issue_to_address>
**Release notes permit stored script injection**
When an untrusted contributor's curated notes containing active HTML are merged and published, `check()` validates Markdown structure but does not sanitize raw HTML; an intro containing `<svg onload=alert(1)>` passes, and `body()` preserves it. MkDocs renders the curated file as a docs page, so opening that page executes attacker-supplied script in the site origin.
Sanitize Markdown with a strict HTML allowlist before it is added to the docs or release body, or reject raw HTML and event-handler attributes during validation.
Also at `scripts/release_notes.py:513`.
</issue_to_address>
### Comment 3
<location path=".github/workflows/release.yml" line_range="566" />
<code_context>
+ # ones (generated ones are left as they are)
if [[ "${state}" != "published" ]]; then
gh release upload "${TAG}" dist/* --clobber
edit+=(--notes-file "${notes_file}")
+ elif [[ -f "${curated}" ]]; then
+ edit+=(--notes-file "${notes_file}")
</code_context>
<issue_to_address>
**Concurrent note edits are lost**
When a maintainer edits a published release body while a `publish` rerun is generating its notes and before it runs `gh release edit`, the publish job writes the body generated from the tagged commit over the published release body, so a maintainer’s concurrent correction in GitHub disappears.
Avoid replacing published release bodies during reruns, or coordinate edits so they occur only after the rerun completes.
</issue_to_address>
### Comment 4
<location path="scripts/release_notes.py" line_range="679-681" />
<code_context>
+ others = [
+ path
+ for path in releases.glob("*.md")
+ if path.name != notes.name and NOTES_NAME.fullmatch(path.name)
+ ]
+ return notes if others else None
+
+
</code_context>
<issue_to_address>
**Deleting notes disables the requirement**
When all existing curated release-note files are removed or renamed, all version-named files in `docs/releases/` are removed or renamed, so `missing_notes` finds no other release notes and `require` allows the next release to omit curated notes. The repository then silently reverts to generated-only notes despite the policy having been established.
Persist whether curated notes have been adopted, or determine that from published release history, rather than inferring it only from files currently present.
</issue_to_address>
### Comment 5
<location path="scripts/release_notes.py" line_range="86" />
<code_context>
+UNDERLINE = re.compile(r" {0,3}(?:(?:-[ \t]*)+|=+[ \t]*|(?:[*_][ \t]*){3,})")
+# Opening and closing lines of fenced code blocks: a block closes with a line
+# of the same character, at least as long as the opening one, and nothing else
+FENCE = re.compile(r"[ \t]*(?P<marker>`{3,}|~{3,})(?P<rest>.*)")
+# Top-level list items (bullets or numbered)
+ITEM = re.compile(r"(?:[-*+]|[0-9]+[.)])(?:[ \t]|$)")
</code_context>
<issue_to_address>
**Invalid fences hide headings**
When curated notes use a backtick fence opener whose info string contains a backtick, `FENCE` accepts the invalid opener, and `_Checker._code` then ignores headings until a matching closing line. Curated notes can therefore pass `check` while containing a rendered `## Commits`; when the workflow appends generated notes, the release body has an extra section or its generated notes are rendered as code.
Reject backtick fence openers whose info string contains a backtick before treating subsequent lines as code.
Also at `scripts/release_notes.py:343`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 5 findings to address first, and a validation or assembly mistake could publish incorrect release notes alongside a release. Reverting the workflow would not change notes already published, but the release notes can be corrected, so the impact is bounded and repairable.
Blocking findings: scripts/release_notes.py:781, scripts/release_notes.py:471, .github/workflows/release.yml:566, scripts/release_notes.py:681, scripts/release_notes.py:86
A release commit whose docs/releases/<version>.md is a symbolic link (of the file, or of a directory on the way) could make the release publish another file as its body, e.g., /proc/self/environ with the token of the "Create release" step. The "Check release notes" step in prepare and "Create release" in publish now accept only a regular file of the repository (Sourcery review). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Linked issuesChecked at commit dd8faad #125 ci: publish curated release notes · 4 of 5 met
|
Summary
The release workflow created releases with GitHub's generated notes only, to be edited by hand into the agreed format after publishing. The org's release pattern creates the release with the curated notes followed by the generated ones. This ports cloud-registry's mechanism, so that the 0.3.0 release is published in the agreed format:
docs/releases/<version>.md(parts 1 and 2 of the format: intro and grouped sections), listed in thenavofmkdocs.yml.scripts/release_notes.pyis cloud-registry's (canonical, named in its header), with commandscheck,body,requireandfirst. OnlyDOCS_HOSTandREPOSITORIESdiffer: links to versions that move are checked for Pubgrade's Read the Docs and both repositories (Pubgrade and Pubgrade-Sidecar). Pubgrade-Sidecar gets the same script (ci: publish curated release notes Pubgrade-Sidecar#73).prepare, new step "Check release notes": fails before anything is pushed if the notes containTODO, aren't in the agreed format, or are missing once any release has curated notes.publish, "Create release": with curated notes, the body is the curated notes, then## Commitswith the generated notes (without "What's Changed"), then the**Full Changelog**line. Without them, the generated notes alone, as before. A re-run of a published release replaces its notes only with curated ones.test_curated_noteschecks every file indocs/releases/, which must also have noTODO, so that CI rejects unfinished notes before the tag (a failed release can't reuse its tag).docs/development.md: the format, the pre-tag checks, thenaventry (after "Development", before the Sidecar section thatdocs/hooks.pyappends), and that a re-run replaces published notes.The first curated notes (
docs/releases/0.3.0.md) come with the release-prep pull request.Closes #125
Verification
pytest --cov: 900 passed, 1 skipped, coverage 100%.test_curated_notesis skipped here (no notes yet); with a valid notes file that containsTODOit fails, without it it passes (checked with a temporarydocs/releases/9.9.9.md, removed).ruff check .,ruff format --check .,mypy: passed.pre-commit run --all-files: passed, exceptgitleaksand theactionlinthook, which couldn't install in the sandbox;actionlint1.7.12 with shellcheck 0.11.0 run directly onrelease.yml,ci.ymlandscan.yml: passed.gitleaksruns in CI.mkdocs build --strict(submoduleexternal/pubgrade-sidecarchecked out): passed.release.ymlwith yq and run with a stubgh(script in the agent's scratchpad): with curated notes and no release yet, the release is created as a draft and published with the curated notes,## Commitsand the Full Changelog line; for a published release, its notes are replaced with the curated ones; without curated notes, a published release's notes are left alone.release.yml, run against a regular file (passes), a file symlink, a directory symlink and a dangling symlink (all fail) and no notes (passes). Notes dry run andactionlintpassed again.Declined review findings
elixir-cloud-aai/.githubwould be a change for all repos that use it; its header now names the canonical copy and the two constants that differ, so a sync replaces everything else.TODOcheck into the script (quality and adversarial, medium/low): kept in the workflow, as in cloud-registry, so that the copies stay the same. CI now rejectsTODOthroughtest_curated_notesinstead, and the pre-tag steps in the docs run the samegrep.TODO/TBDcheck (adversarial, low): as above; cloud-registry's rule isTODO.release.yml(quality, low): it follows cloud-registry's workflow comment.publishre-run (Sourcery, medium): a re-run is a rare recovery step, and the docs say that it writes the tagged notes back over hand edits.require(Sourcery, medium): that takes a reviewed PR that also removes them from the docs; same rule as cloud-registry's canonical script.Open questions
None.
🤖 Generated with Claude Code
Summary by Sourcery
Publish releases with validated curated notes and GitHub-generated commit details while enforcing the organization-wide release note format.
New Features:
Bug Fixes:
Enhancements:
CI:
Documentation:
Tests: