From 66c24c5aff061e11fbff28f992db585813c95a80 Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Mon, 23 Nov 2026 11:50:33 +0100 Subject: [PATCH 1/9] ci(release): gather release notes from release-note blocks in PR bodies Release notes now come from fenced ```release-note blocks in PR bodies instead of GoReleaser-generated changelogs from commit subjects. - Add scripts/check-release-note.sh: every PR must carry a non-empty release-note block (or NONE); a PR whose title or a commit subject carries the '!' breaking-change marker must start the block with 'action required' and cannot use NONE or /release-note-none - Add .github/workflows/release-note-check.yml: runs the validator from the PR base SHA (trusted revision), skips when the script is absent at the base (bootstrap), and best-effort syncs the release-note-action-required label so the gatherer lists the note under Urgent Upgrade Notes - release.yml gathers notes with the Kubernetes release-notes tool: START_SHA from first-parent history after the previous tag, commits listed from the tag SHA, notes passed to GoReleaser via --release-notes - Reject quoted NONE sentinels (the gatherer publishes them literally); fail when a body has both a note and a leftover NONE block or /release-note-none tag - Emit the action-required marker whenever the accepted note starts with 'action required'; annotations go to stderr; the marker is written to GITHUB_OUTPUT - Update COMMITS.md, the PR template, vouch-system.md, the cutting-releases skill, .gitlint and gitlint docs for the new contract; add regression tests including real-CRLF and marker assertions Closes #9164 Assisted-By: claude-sonnet-4-5(pi) Signed-off-by: Hector Martinez --- .github/pull_request_template.md | 12 + .github/workflows/release-note-check.yml | 90 ++++++++ .github/workflows/release.yml | 86 ++++++- .gitlint | 3 +- .goreleaser.yml | 38 +--- AGENTS.md | 8 +- COMMITS.md | 95 +++++--- CONTRIBUTING.md | 15 +- Makefile | 1 + docs/contributing/vouch-system.md | 2 +- gitlint_rules/forbidden_type_scope.py | 9 +- gitlint_rules_test.py | 13 +- scripts/check-release-note-test.sh | 278 +++++++++++++++++++++++ scripts/check-release-note.sh | 136 +++++++++++ skills/cutting-releases/SKILL.md | 25 +- skills/cutting-releases/post-flight.md | 4 +- 16 files changed, 717 insertions(+), 98 deletions(-) create mode 100644 .github/workflows/release-note-check.yml create mode 100755 scripts/check-release-note-test.sh create mode 100755 scripts/check-release-note.sh diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 69b6fa021e..71a6492c9a 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -11,6 +11,18 @@ - [ ] `make lint` passes (stage changes first, then run) - [ ] Tests added/updated for new or modified logic +## Release Note + + +```release-note +NONE +``` + ## Checklist - [ ] PR title follows [Conventional Commits](COMMITS.md) (correct type, `!` for breaking changes) - [ ] Commits are signed off (DCO) — human and human-directed agent sessions only diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml new file mode 100644 index 0000000000..b4acc07abf --- /dev/null +++ b/.github/workflows/release-note-check.yml @@ -0,0 +1,90 @@ +name: Release Note Check + +on: + pull_request: + types: [opened, synchronize, reopened, edited] + branches: [main] + merge_group: + +permissions: + contents: read + pull-requests: write + issues: write + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + release-note-check: + # The check already ran on the PR head; merge-group commits carry no + # pull_request event payload to re-check, so pass (skip) there. This + # keeps the check safe to mark required without stalling the queue. + if: github.event_name == 'pull_request' + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + # Check out the PR's base ref, not the PR head: the validator must + # come from a trusted revision so a PR cannot neuter its own check + # by editing scripts/check-release-note.sh. The PR body, title and + # commit subjects come from the API below, not from the checkout. + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.base.sha }} + fetch-depth: 1 + + # Fetch the PR body, title and commit subjects from the API rather + # than the event payload so every trigger type (including `edited`) + # sees the current state. Fork PRs work too: the PR object lives in + # this repository. + - name: Check release-note block + id: check + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + set -euo pipefail + # Bootstrap: the validator ships in this repository. When the + # PR's base predates the script (e.g. this PR itself), skip + # rather than fail; the check becomes enforcing once the script + # has landed on main. + if [[ ! -f scripts/check-release-note.sh ]]; then + echo "::warning::scripts/check-release-note.sh not present at the PR base; skipping release-note check." + exit 0 + fi + PR_JSON=$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}") + PR_BODY=$(jq -r '.body // ""' <<<"${PR_JSON}") + PR_TITLE=$(jq -r '.title // ""' <<<"${PR_JSON}") + # Per-item jq transform with --paginate is safe; no cross-page + # aggregation happens here (see docs/contributing/shell-scripting.md). + COMMIT_SUBJECTS=$(gh api --paginate "repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/commits" \ + --jq '.[] | .commit.message | split("\n")[0]') + PR_BODY="${PR_BODY}" PR_TITLE="${PR_TITLE}" COMMIT_SUBJECTS="${COMMIT_SUBJECTS}" \ + bash scripts/check-release-note.sh + # The script appends action-required=1 to GITHUB_OUTPUT when the + # accepted note starts with "action required". + + # The release-notes gatherer lists a note under "Urgent Upgrade + # Notes" only when the PR carries this label (it also strips the + # "action required:" prefix from the note text), so keep the label in + # sync with the check result. + - name: Sync action-required label + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + ACTION_REQUIRED: ${{ steps.check.outputs.action-required }} + run: | + set -euo pipefail + # Best-effort: fork PRs run with a read-only token and cannot + # create or add labels. The check itself already passed; do not + # fail valid fork PRs here. + if [[ "${ACTION_REQUIRED:-}" == "1" ]]; then + gh label create release-note-action-required --color b60205 \ + --description "Release-note block starts with 'action required'" --force \ + || echo "::warning::could not create label (fork PR?)" + gh pr edit "${PR_NUMBER}" --add-label release-note-action-required \ + || echo "::warning::could not add label (fork PR?)" + else + # Fails if the label is absent; that is the common case. + gh pr edit "${PR_NUMBER}" --remove-label release-note-action-required || true + fi diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7844fa5a3a..8604869d1b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,12 @@ jobs: release: needs: [validate-agents, resolve-agents, recheck-tag] runs-on: ubuntu-24.04 + # pull-requests: read is needed by release-notes generate, which reads + # merged PR bodies to gather the release-note blocks. + permissions: + contents: write + id-token: write + pull-requests: read # Historically ~2 minutes. Bounded so a hung publish cannot hold the # tag-agents sync (and the default 6h limit) open. timeout-minutes: 20 @@ -51,6 +57,81 @@ jobs: fi echo "current=${TAG} previous=${PREV:-}" + # Release notes come from `release-note` blocks in PR bodies (see + # COMMITS.md, "Release notes"), gathered with the Kubernetes + # release-notes tool — the same approach kubearchive uses. The tool + # reads the blocks from the merged PRs in the tag range, skips NONE + # entries, and renders markdown. GoReleaser then publishes that + # markdown instead of its commit-subject changelog. + - name: Install release-notes + env: + # SHA-256 of release-notes-amd64-linux from the v0.17.1 release. + # Update the URL and this digest together (see + # scripts/renovate/ for the checksum-pinning convention). + RELEASE_NOTES_SHA256: 16e0ada3e3602c229e97fa789ea97c7d128710d7fe1fee9f12c00f7eaa770d6a + run: | + set -euo pipefail + curl -fsSLo "${RUNNER_TEMP}/release-notes" \ + https://github.com/kubernetes/release/releases/download/v0.17.1/release-notes-amd64-linux + echo "${RELEASE_NOTES_SHA256} ${RUNNER_TEMP}/release-notes" | sha256sum -c - + chmod +x "${RUNNER_TEMP}/release-notes" + sudo mv "${RUNNER_TEMP}/release-notes" /usr/local/bin/release-notes + + - name: Generate release notes from PR bodies + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + set -euo pipefail + # Previous tag: for a final release, the last final release, so + # the notes span the whole release. For an rc, the tag + # immediately before this one (usually the previous rc), so an + # rc only lists what changed since that tag — matching + # GoReleaser's default previous-tag resolution for rc tags. + TAGS=$(git tag --merged "${TAG}^{commit}" --sort=-v:refname --list 'v[0-9]*.[0-9]*.[0-9]*') + case "${TAG}" in + *-*) PREV=$(printf '%s\n' "$TAGS" | grep -vxF -e "$TAG" | head -n1 || true) ;; + *) PREV=$(printf '%s\n' "$TAGS" | grep -v -e '-' | grep -vxF -e "$TAG" | head -n1 || true) ;; + esac + if [[ -z "${PREV}" ]]; then + # Static message: interpolating TAG here would need workflow-command + # escaping (%0A/%0D) to stay injection-safe. + echo "::error::Could not find a previous release tag before the current tag" + exit 1 + fi + echo "Gathering notes from ${PREV} to ${TAG}" + # The tool lists commits from START_SHA's commit date onward + # (inclusive). Use the first first-parent commit after PREV: + # picking the oldest-dated commit in the range would open the + # window before PREV (PR-branch commits can carry dates older + # than PREV) and re-list PRs from the previous release. + RANGE=$(git rev-list --first-parent --reverse "${PREV}..${TAG}") + if [[ -n "${RANGE}" ]]; then + START_SHA=$(head -n1 <<<"${RANGE}") + else + # PREV and TAG share a commit (a re-tag); fall back to PREV. + START_SHA=$(git rev-list -n1 "${PREV}") + fi + END_SHA=$(git rev-list -n1 "${TAG}") + export START_SHA END_SHA + # The tool reads its range and branch from these env vars. Use + # the tag's SHA as the listing ref (the `sha` parameter accepts + # a SHA): listing from main would include PRs merged to main + # after the tag but dated inside the window. --required-author="" + # includes bot-authored PRs (agents open many of our PRs). Write + # outside the checkout: GoReleaser refuses a dirty git tree. + export BRANCH="${END_SHA}" + release-notes generate \ + --required-author="" \ + --dependencies=false \ + --output "${RUNNER_TEMP}/release-notes-body.md" \ + --org fullsend-ai --repo fullsend + # Prepend the header prepend-release-highlights.sh expects, so + # the release-highlights step keeps working with the + # gathered-notes body. + printf '## Changelog\n\n' | cat - "${RUNNER_TEMP}/release-notes-body.md" \ + > "${RUNNER_TEMP}/release-notes.md" + # GoReleaser signs the release here. Installed CLIs only accept a # signature made by this workflow file, for the tag, on a # GitHub-hosted runner (internal/selfupdate/verify.go). Renaming this @@ -60,7 +141,10 @@ jobs: uses: goreleaser/goreleaser-action@f06c13b6b1a9625abc9e6e439d9c05a8f2190e94 # v7.2.3 with: version: "~> v2" - args: release --clean + # --release-notes replaces the changelog with the markdown + # gathered from PR bodies above. The path is outside the + # checkout so the git tree stays clean. + args: release --clean --release-notes ${{ runner.temp }}/release-notes.md env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }} diff --git a/.gitlint b/.gitlint index fab3a5e1ca..e8216dfd8b 100644 --- a/.gitlint +++ b/.gitlint @@ -7,7 +7,6 @@ extra-path=gitlint_rules/ line-length=100 # Conventional commit types allowed in this repo. -# Matches the types documented in COMMITS.md and parsed by -# GoReleaser for release notes. +# Matches the types documented in COMMITS.md. [contrib-title-conventional-commits] types=feat,fix,refactor,docs,test,chore,ci,perf,build,style diff --git a/.goreleaser.yml b/.goreleaser.yml index 29b3d9a2bf..b89d2f3e4f 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -2,7 +2,7 @@ version: 2 git: # Ignore major-version floating tags (v0, v1, ...) so they don't - # confuse GoReleaser's previous-tag detection for changelogs. + # confuse GoReleaser's tag detection. ignore_tags: - v0 - v1 @@ -31,35 +31,11 @@ archives: checksum: name_template: checksums.txt -changelog: - use: github - sort: asc - filters: - exclude: - - '^Merge ' - - '^ci(\(.*\))?:' - - '^docs(\(.*\))?:' - - '^test(\(.*\))?:' - - '^chore(\(.*\))?:' - - '^build(\(.*\))?:' - - '^style(\(.*\))?:' - # Groups match in list order and the first match wins, so Breaking - # Changes must stay first to pull `!` commits out of the type groups. - groups: - - title: Breaking Changes - regexp: '^[a-z]+(\([^)]*\))?!:' - order: 0 - - title: Features - regexp: '^.*?feat(\([^)]+\))??!?:.+$' - order: 1 - - title: Bug Fixes - regexp: '^.*?fix(\([^)]+\))??!?:.+$' - order: 2 - - title: Refactoring - regexp: '^.*?refactor(\([^)]+\))??!?:.+$' - order: 3 - - title: Others - order: 999 +# Release notes are not built from commit subjects. The release +# workflow gathers `release-note` blocks from merged PR bodies with the +# Kubernetes release-notes tool and passes the markdown to GoReleaser +# via `--release-notes` (see .github/workflows/release.yml and +# COMMITS.md, "Release notes"). # `fullsend self-update` verifies this signature. Read the comment on the # GoReleaser step in .github/workflows/release.yml before changing it. @@ -79,7 +55,7 @@ release: name: fullsend name_template: "{{ .Tag }}{{ if and .TagSubject (ne .TagSubject .Tag) }}: {{ .TagSubject }}{{ end }}" prerelease: auto - # The changelog above lists fullsend commits only. The agents release + # The release notes above list fullsend changes only. The agents release # for the same tag (created by release.yml's tag-agents job) carries the # agents changelog, so link it from every release. footer: | diff --git a/AGENTS.md b/AGENTS.md index c5e7f53275..00e37c49d5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,8 +41,12 @@ full documentation site. binary to avoid stale state. See [Go Code § Running the fullsend CLI](docs/contributing/go-code.md#running-the-fullsend-cli). - Follow [COMMITS.md](COMMITS.md) when writing or reviewing commit messages - and PR titles. Commit prefixes feed release notes; breaking changes require - the `!` marker in both commit subjects and PR titles; a missing `!` is an + and PR titles. Every PR must carry a `release-note` block in its body (CI + enforces it); release notes come from those blocks, not commit prefixes. + Breaking changes require the `!` marker in both commit subjects and PR + titles, and an `action required` release-note block (CI labels such PRs + `release-note-action-required` so the note lands under Urgent Upgrade + Notes); a missing `!` is an important-severity review finding; forbidden combinations (e.g. `fix(ci)`/`fix(e2e)`) are enforced as errors. - Human and human-driven agent commits require DCO sign-off (`git commit -s`); diff --git a/COMMITS.md b/COMMITS.md index c3455ab1c4..1f5972570b 100644 --- a/COMMITS.md +++ b/COMMITS.md @@ -1,6 +1,8 @@ # Commit Messages -This project uses [Conventional Commits](https://www.conventionalcommits.org/). Every commit on `main` feeds the auto-generated release notes (via GoReleaser), so getting the prefix right matters. You **must** consult this file when writing or reviewing commit messages. +This project uses [Conventional Commits](https://www.conventionalcommits.org/). Gitlint enforces the prefixes on every commit and PR title, so getting them right matters. You **must** consult this file when writing or reviewing commit messages. + +Release notes no longer come from commit subjects. They come from a `release-note` block in the PR body — see [Release notes](#release-notes) below. ## Format @@ -14,22 +16,46 @@ This project uses [Conventional Commits](https://www.conventionalcommits.org/). ## Types -| Type | Purpose | Appears in release notes? | +| Type | Purpose | Needs a release-note entry? | |---|---|---| -| `feat` | New user-facing functionality | Yes — under **Features** | -| `fix` | Bug fix visible to users | Yes — under **Bug Fixes** | -| `refactor` | Code restructuring (no behavior change) | Yes — under **Refactoring** | -| `docs` | Documentation only | No | -| `test` | Adding or updating tests | No | -| `chore` | Maintenance (CI, deps, tooling) | No | -| `ci` | CI/CD pipeline changes | No | -| `perf` | Performance improvement | Yes — under **Others** | -| `build` | Build system or dependency changes | No | -| `style` | Formatting only, no logic change | No | +| `feat` | New user-facing functionality | Yes | +| `fix` | Bug fix visible to users | Yes | +| `refactor` | Code restructuring (no behavior change) | Usually `NONE` | +| `docs` | Documentation only | Usually `NONE` | +| `test` | Adding or updating tests | `NONE` | +| `chore` | Maintenance (CI, deps, tooling) | `NONE` | +| `ci` | CI/CD pipeline changes | `NONE` | +| `perf` | Performance improvement | Yes | +| `build` | Build system or dependency changes | `NONE` | +| `style` | Formatting only, no logic change | `NONE` | + +## Release notes + +Every PR must contain a fenced `release-note` block in its body. The PR +template carries the block with a `NONE` default. CI rejects a PR whose +block is missing or empty. + +Write the block for users, not for reviewers. One or more lines of prose. +Write `NONE` when the change has no effect users can see. Start the block +with `action required` when the change breaks something. + +At release time, the release pipeline reads the blocks from the merged +PRs in the tag range (with the Kubernetes `release-notes` tool), skips +`NONE` entries, and publishes the gathered markdown. Commit subjects no +longer feed the release notes. + +Example block: + +```release-note +action required: the `role` field in harness files is now required. +Add `role: ` to any harness file that lacks it. +``` ## `feat` is for end users -The `feat` prefix populates the **Features** section of our release notes. End users read that list to decide whether to upgrade. Reserve `feat` for changes an end user would recognize as new capability: +The `feat` prefix marks user-facing functionality. End users read the +release notes to decide whether to upgrade. Reserve `feat` for changes an +end user would recognize as new capability: - A new CLI command or flag they can invoke - A new behavior they interact with (e.g., the agent now comments on their PR with a new kind of analysis) @@ -45,7 +71,7 @@ The `feat` prefix populates the **Features** section of our release notes. End u Apply the same discipline to `fix` — bumping a dependency version is `chore`, not `fix`, unless it corrects a user-visible bug. Removing a trailing blank line is `style`, not `fix`. -**When in doubt, prefer `refactor` or `chore` over `feat` or `fix`.** A change miscategorized as `refactor` is harmless — it shows up in a lower section of the release notes. A change miscategorized as `feat` erodes the signal of the Features list. +**When in doubt, prefer `refactor` or `chore` over `feat` or `fix`.** A change miscategorized as `refactor` is harmless — its release-note block can still say what matters. A change miscategorized as `feat` erodes the signal of the release notes. ## Scope @@ -53,7 +79,7 @@ The parenthesized scope is optional but encouraged. Use it to identify the subsy ### Forbidden type + scope combinations -Some type/scope pairs are **enforced as errors** by gitlint (rule `UC1`). These combinations mislead users by putting infrastructure changes in user-facing release-note sections. +Some type/scope pairs are **enforced as errors** by gitlint (rule `UC1`). These combinations mislead users by putting infrastructure changes in user-facing release-note territory. | Forbidden | Why | Use instead | |---|---|---| @@ -64,16 +90,21 @@ Some type/scope pairs are **enforced as errors** by gitlint (rule `UC1`). These ## Breaking changes -Breaking changes **must** be marked in both commit messages and PR titles. -GoReleaser builds release notes from the subject line of every commit in the -release range (`use: github` in `.goreleaser.yml`). PRs land through the merge -queue as merge commits, whose `Merge pull request …` subjects are excluded, so -the PR title does not appear in the release notes: each breaking commit's own -subject must carry the `!`. A breaking commit whose subject lacks `!` is filed -under Features, Bug Fixes, or Refactoring instead of **Breaking Changes**, so -users reading the release notes get no warning. This has caused -real incidents — users upgraded with no warning that their agents would stop -working (#8366). +Breaking changes **must** be marked in three places: the `!` suffix in +every commit subject and the PR title, and an `action required` +`release-note` block in the PR body. + +The release-note block is what users see. When the block starts with +`action required`, the release-note check labels the PR +`release-note-action-required`, and the release pipeline lists the note +under **Urgent Upgrade Notes** in the published release notes (the +gatherer strips the `action required:` prefix from the note text itself). +The `!` marker stays required for reviewers and tooling. CI rejects a +`NONE` release-note block — and any block that does not start with +`action required` — when the PR title or any commit subject carries the +`!` marker, so a breaking PR cannot ship without a warning. This closes +the gap that caused real incidents — users upgraded +with no warning that their agents would stop working (#8366). **How to mark a breaking change:** @@ -81,9 +112,9 @@ working (#8366). 2. Include a `BREAKING CHANGE:` trailer in the commit body explaining what breaks and how to migrate Both the `!` suffix and the trailer are required. The `!` suffix signals the -breaking change to human reviewers and puts the commit under **Breaking -Changes** in the release notes; GoReleaser only reads subjects, so a trailer -alone does not. The trailer tells users what to do about it. +breaking change to human reviewers and to the release-note CI check. The +trailer tells readers of the commit what to do about it. The `action required` +release-note block tells users. **How to tell if your change is breaking:** @@ -130,6 +161,8 @@ When reviewing PRs, check that commit messages and PR titles use the correct typ - **Missing `!` on breaking changes** — if the diff removes a field, renames a flag, adds a required input, tightens validation, or otherwise breaks existing usage, the PR title and commit messages **must** carry the `!` - suffix. Flag a missing `!` as an important-severity finding. Every commit - subject matters because GoReleaser lists each one in the user-facing release - notes. The PR title is not one of them, because PRs land as merge commits. + suffix. Flag a missing `!` as an important-severity finding. +- **Missing or wrong `release-note` block** — every PR needs a valid block. + A breaking PR (title or commit subject carries `!`) must start its block + with `action required`; a `NONE` block there is an important-severity + finding. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cd233d7f77..97991dc415 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,12 +43,19 @@ contribution. - On macOS or a Linux distribution other than Ubuntu, `make ci-local` runs the same checks in a container that matches the CI runner, so local results predict CI (see [`hack/ci-local`](hack/ci-local/README.md)). +- Every PR must carry a `release-note` block in its body — the PR template + provides one with a `NONE` default. CI rejects a PR whose block is missing + or empty. See [COMMITS.md](COMMITS.md#release-notes) for how to write it. - **If your PR introduces a breaking change**, the PR title and every breaking commit's subject must carry the `!` suffix (e.g., `feat(harness)!: require - role field`). GoReleaser builds release notes from commit subjects, not the - PR title — a missing `!` on a breaking commit means users get no warning - before upgrading. See [COMMITS.md](COMMITS.md#breaking-changes) for how to - identify breaking changes and what to include in the commit body. + role field`), and the PR's `release-note` block must start with + `action required`. The block is what users see — CI labels the PR + `release-note-action-required` so the note is listed under **Urgent + Upgrade Notes** in the release, and CI rejects a `NONE` block (or any + block without the prefix) on a PR that carries the `!` marker, so a + breaking change cannot ship without a warning. See + [COMMITS.md](COMMITS.md#breaking-changes) for how to identify breaking + changes and what to include in the commit body. - Wrap prose in Markdown files at about 80 columns, so diffs show only the lines you changed. Tables, code blocks, headings, and long URLs are exceptions. See diff --git a/Makefile b/Makefile index e4e9e0f2e1..8b82f05595 100644 --- a/Makefile +++ b/Makefile @@ -187,6 +187,7 @@ define run-timed endef script-test: + $(call run-timed,bash scripts/check-release-note-test.sh) $(call run-timed,bash scripts/check-live-test-relevance-test.sh) $(call run-timed,bash scripts/check-e2e-authorization-test.sh) $(call run-timed,bash scripts/vouch-sweep-test.sh) diff --git a/docs/contributing/vouch-system.md b/docs/contributing/vouch-system.md index 2c8fc16a6e..41a23c6260 100644 --- a/docs/contributing/vouch-system.md +++ b/docs/contributing/vouch-system.md @@ -10,4 +10,4 @@ - The vouch gate is separate from the e2e authorization gate. Vouch determines whether a PR stays open; e2e authorization determines whether tests run. - PRs from unvouched external contributors are automatically closed with a comment linking to the vouch process. The PR is closed before the comment is posted, and the comment (marker ``) is posted once per PR, even when overlapping runs or a reopen close it again. - An API error never closes a PR: a failed `VOUCHED.td` read aborts the sweep, and a failed permission lookup skips that PR until the next run. -- PRs should follow the PR template structure: Summary, Related Issue, Changes, Testing, Checklist. +- PRs should follow the PR template structure: Summary, Related Issue, Changes, Testing, Release Note, Checklist. diff --git a/gitlint_rules/forbidden_type_scope.py b/gitlint_rules/forbidden_type_scope.py index 833d3c309e..7def4a2bf7 100644 --- a/gitlint_rules/forbidden_type_scope.py +++ b/gitlint_rules/forbidden_type_scope.py @@ -1,9 +1,10 @@ """Gitlint rule that forbids misleading type+scope combinations. -Types like ``feat`` and ``fix`` appear in user-facing release notes. -Scopes like ``ci`` and ``e2e`` describe infrastructure, not user-visible -changes. Using them together pollutes the release notes with entries -that mean nothing to end users. +Types like ``feat`` and ``fix`` describe user-facing changes, which now +belong in the PR body's ``release-note`` block rather than the commit +subject. Scopes like ``ci`` and ``e2e`` describe infrastructure, not +user-visible changes. Using them together produces commit subjects that +misleadingly suggest user-facing infrastructure changes. """ import re diff --git a/gitlint_rules_test.py b/gitlint_rules_test.py index 83705cb2b1..58aa8c95af 100644 --- a/gitlint_rules_test.py +++ b/gitlint_rules_test.py @@ -5,7 +5,6 @@ from pathlib import Path import pytest -import yaml from gitlint.rules import RuleViolation from gitlint_rules.forbidden_type_scope import ForbiddenTypeScope @@ -92,7 +91,7 @@ def test_ignores_non_conventional(title): assert not violations -# --- .gitlint, COMMITS.md and .goreleaser.yml must agree on commit types --- +# --- .gitlint and COMMITS.md must agree on commit types --- ROOT = Path(__file__).parent @@ -104,7 +103,7 @@ def gitlint_types(): def commits_md_rows(): - """Map type -> 'Appears in release notes?' cell from the COMMITS.md types table.""" + """Map type -> 'Needs a release-note entry?' cell from the COMMITS.md types table.""" rows = re.findall( r"^\| `(\w+)` \| [^|]+ \| ([^|]+) \|$", (ROOT / "COMMITS.md").read_text(), re.M ) @@ -113,11 +112,3 @@ def commits_md_rows(): def test_gitlint_types_match_commits_md(): assert gitlint_types() == set(commits_md_rows()) - - -@pytest.mark.parametrize( - "ctype", sorted(t for t, notes in commits_md_rows().items() if notes == "No") -) -def test_hidden_types_excluded_from_release_notes(ctype): - goreleaser = yaml.safe_load((ROOT / ".goreleaser.yml").read_text()) - assert f"^{ctype}(\\(.*\\))?:" in goreleaser["changelog"]["filters"]["exclude"] diff --git a/scripts/check-release-note-test.sh b/scripts/check-release-note-test.sh new file mode 100755 index 0000000000..65692cc197 --- /dev/null +++ b/scripts/check-release-note-test.sh @@ -0,0 +1,278 @@ +#!/usr/bin/env bash +# check-release-note-test.sh — Tests for check-release-note.sh +# +# Run from the repo root: +# bash scripts/check-release-note-test.sh + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT="${SCRIPT_DIR}/check-release-note.sh" +FAILURES=0 + +run_case() { + local desc="$1" expected="$2" + shift 2 + local actual + if "$@" bash "${SCRIPT}" >/dev/null 2>&1; then + actual="pass" + else + actual="fail" + fi + if [[ "${actual}" == "${expected}" ]]; then + echo "ok — ${desc}" + else + echo "FAIL — ${desc} (expected ${expected}, got ${actual})" + FAILURES=$((FAILURES + 1)) + fi +} + +# Like run_case, but also asserts on the script's stdout: whether the +# "release-note: action-required" marker is present. That marker drives +# the release-note-action-required label, which is the only way a note +# lands under Urgent Upgrade Notes. +run_marker_case() { + local desc="$1" expected_exit="$2" expected_marker="$3" + shift 3 + local actual_exit actual_marker="absent" + local out + out=$("$@" bash "${SCRIPT}" 2>/dev/null) && actual_exit="pass" || actual_exit="fail" + if grep -qx 'release-note: action-required' <<<"${out}"; then + actual_marker="present" + fi + if [[ "${actual_exit}" == "${expected_exit}" && "${actual_marker}" == "${expected_marker}" ]]; then + echo "ok — ${desc}" + else + echo "FAIL — ${desc} (expected ${expected_exit}/${expected_marker}, got ${actual_exit}/${actual_marker})" + FAILURES=$((FAILURES + 1)) + fi +} + +BODY_WITH_NONE="## Summary + +Does a thing. + +\`\`\`release-note +NONE +\`\`\` +" + +BODY_WITH_NOTE="## Summary + +Does a thing. + +\`\`\`release-note +The fullsend CLI now frobs the widget. +\`\`\` +" + +BODY_WITH_ACTION_REQUIRED="## Summary + +Breaks a thing. + +\`\`\`release-note +action required: the widget flag is now required. +\`\`\` +" + +BODY_EMPTY_BLOCK="## Summary + +Does a thing. + +\`\`\`release-note +\`\`\` +" + +BODY_NO_BLOCK="## Summary + +Does a thing. +" + +BODY_INDENTED_NONE="## Summary + +\`\`\`release-note + NONE +\`\`\` +" + +BODY_NONE_MIXED_CASE="## Summary + +\`\`\`release-note +None +\`\`\` +" + +BODY_NA="## Summary + +\`\`\`release-note +n/a +\`\`\` +" + +BODY_QUOTED_NONE="## Summary + +\`\`\`release-note +\"NONE\" +\`\`\` +" + +BODY_ACTION_REQUIRED_MIXED_CASE="## Summary + +\`\`\`release-note +Action Required: the widget flag is now required. +\`\`\` +" + +BODY_MULTI_LINE="## Summary + +\`\`\`release-note +The CLI now supports frobbing. + +Users must pass --frob. +\`\`\` +" + +BODY_NONE_PLUS_LINES="## Summary + +\`\`\`release-note +NONE + +Except this extra line. +\`\`\` +" + +# Real CRLF bytes: the script must strip carriage returns before parsing. +BODY_CRLF_NONE=$'## Summary\r\n\r\n```release-note\r\nNONE\r\n```\r\n' + +BODY_SECOND_NONE_BLOCK="## Summary + +\`\`\`release-note +action required: the widget flag is now required. +\`\`\` + +\`\`\`release-note +NONE +\`\`\` +" + +BODY_RELEASE_NOTE_NONE_TAG="## Summary + +\`\`\`release-note +action required: the widget flag is now required. +\`\`\` + +/release-note-none +" + +BODY_NOTE_PLUS_LEFTOVER_NONE="## Summary + +\`\`\`release-note +The fullsend CLI now frobs the widget. +\`\`\` + +\`\`\`release-note +NONE +\`\`\` +" + +BODY_ACTION_REQUIRED_NON_BREAKING="## Summary + +\`\`\`release-note +action required: the widget flag is now required. +\`\`\` +" + +BREAKING_TITLE="feat(harness)!: require role field" + +# Valid blocks pass. +run_case "NONE block passes" pass env PR_BODY="$BODY_WITH_NONE" +run_case "prose block passes" pass env PR_BODY="$BODY_WITH_NOTE" +run_case "action required block passes" pass env PR_BODY="$BODY_WITH_ACTION_REQUIRED" +run_case "indented NONE passes" pass env PR_BODY="$BODY_INDENTED_NONE" +run_case "multi-line block passes" pass env PR_BODY="$BODY_MULTI_LINE" + +# NONE variants the gatherer treats as "no note" — all pass for +# non-breaking PRs (the note is simply not published). +run_case "None (mixed case) passes" pass env PR_BODY="$BODY_NONE_MIXED_CASE" +run_case "n/a block passes" pass env PR_BODY="$BODY_NA" +run_case "NONE plus extra lines passes (published as a note)" pass \ + env PR_BODY="$BODY_NONE_PLUS_LINES" + +# Quoted sentinels are rejected: the gatherer publishes quoted text +# literally instead of treating it as "no note". +run_case "quoted NONE fails (write NONE without quotes)" fail env PR_BODY="$BODY_QUOTED_NONE" + +# Missing or empty blocks fail. +run_case "no block fails" fail env PR_BODY="$BODY_NO_BLOCK" +run_case "empty block fails" fail env PR_BODY="$BODY_EMPTY_BLOCK" +run_case "empty body fails" fail env PR_BODY="" + +# NONE with a breaking marker fails. +run_case "NONE with breaking PR title fails" fail \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="feat(harness)!: require role field" +run_case "NONE with breaking commit subject fails" fail \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="feat(harness): add thing" \ + COMMIT_SUBJECTS=$'feat(harness): add thing\nfix(mint)!: drop old flag' +run_case "NONE with scoped breaking title fails" fail \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="fix!: remove flag" + +# NONE variants and exclusion markers with a breaking marker fail: the +# gatherer would drop the PR, silently losing the upgrade warning. +run_case "None (mixed case) with breaking title fails" fail \ + env PR_BODY="$BODY_NONE_MIXED_CASE" PR_TITLE="$BREAKING_TITLE" +run_case "n/a with breaking title fails" fail \ + env PR_BODY="$BODY_NA" PR_TITLE="$BREAKING_TITLE" +run_case "quoted NONE with breaking title fails" fail \ + env PR_BODY="$BODY_QUOTED_NONE" PR_TITLE="$BREAKING_TITLE" +run_case "second NONE block with breaking title fails" fail \ + env PR_BODY="$BODY_SECOND_NONE_BLOCK" PR_TITLE="$BREAKING_TITLE" +run_case "/release-note-none tag with breaking title fails" fail \ + env PR_BODY="$BODY_RELEASE_NOTE_NONE_TAG" PR_TITLE="$BREAKING_TITLE" +run_case "CRLF NONE with breaking title fails" fail \ + env PR_BODY="$BODY_CRLF_NONE" PR_TITLE="$BREAKING_TITLE" + +# A real note plus a leftover NONE block fails even without a breaking +# marker: the gatherer would drop the whole PR and the note would never +# be published. +run_case "note plus leftover NONE block fails (non-breaking)" fail \ + env PR_BODY="$BODY_NOTE_PLUS_LEFTOVER_NONE" PR_TITLE="feat(harness): add thing" + +# NONE without a breaking marker passes even when title/commits are set. +run_case "NONE with non-breaking title and commits passes" pass \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="feat(harness): add thing" \ + COMMIT_SUBJECTS=$'feat(harness): add thing\nfix(mint): correct flag' + +# A breaking PR must start its block with "action required" — the +# gatherer strips that prefix and lists the note under "Urgent Upgrade +# Notes" only for labeled, action-required PRs. +run_case "breaking title with prose note fails (no action required)" fail \ + env PR_BODY="$BODY_WITH_NOTE" PR_TITLE="$BREAKING_TITLE" +run_case "breaking title with action required note passes" pass \ + env PR_BODY="$BODY_WITH_ACTION_REQUIRED" PR_TITLE="$BREAKING_TITLE" +run_case "breaking commit subject with action required note passes" pass \ + env PR_BODY="$BODY_WITH_ACTION_REQUIRED" PR_TITLE="feat(harness): add thing" \ + COMMIT_SUBJECTS=$'feat(harness): add thing\nfix(mint)!: drop old flag' +run_case "action required in mixed case with breaking title passes" pass \ + env PR_BODY="$BODY_ACTION_REQUIRED_MIXED_CASE" PR_TITLE="$BREAKING_TITLE" + +# The action-required stdout marker drives the Urgent label. It must be +# present for a valid breaking PR and for any accepted note that starts +# with "action required", and absent otherwise. +run_marker_case "breaking PR emits action-required marker" pass present \ + env PR_BODY="$BODY_WITH_ACTION_REQUIRED" PR_TITLE="$BREAKING_TITLE" +run_marker_case "non-breaking prose note emits no marker" pass absent \ + env PR_BODY="$BODY_WITH_NOTE" PR_TITLE="feat(harness): add thing" +run_marker_case "NONE block emits no marker" pass absent \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="feat(harness): add thing" +run_marker_case "action-required note without '!' still emits marker" pass present \ + env PR_BODY="$BODY_ACTION_REQUIRED_NON_BREAKING" PR_TITLE="feat(harness): add thing" + +# A `!` in prose (not a Conventional Commits marker) must not trip the check. +run_case "NONE with exclamation in title prose passes" pass \ + env PR_BODY="$BODY_WITH_NONE" PR_TITLE="feat(harness): wow!" + +if [[ "${FAILURES}" -gt 0 ]]; then + echo "${FAILURES} test(s) failed" + exit 1 +fi +echo "all tests passed" diff --git a/scripts/check-release-note.sh b/scripts/check-release-note.sh new file mode 100755 index 0000000000..11fb6f342b --- /dev/null +++ b/scripts/check-release-note.sh @@ -0,0 +1,136 @@ +#!/usr/bin/env bash +# check-release-note.sh — Validate the `release-note` block in a PR body. +# +# Release notes are gathered from fenced ```release-note blocks in PR +# bodies (see COMMITS.md, "Release notes"). This script enforces the +# contract on every PR, whether a human or an agent wrote it: +# +# 1. The body must contain a fenced ```release-note block. +# 2. The block must not be empty. +# 3. If the PR title or any commit subject carries the Conventional +# Commits `!` breaking-change marker, the block must start with +# "action required". A NONE block (or any of the variants the +# release-notes gatherer treats as "no note") is rejected instead. +# +# On success the script prints "release-note block OK", plus the line +# "release-note: action-required" when the accepted note starts with +# "action required" (and appends action-required=1 to $GITHUB_OUTPUT when +# set). The release-note-check workflow uses that to label the PR +# `release-note-action-required`, which is what makes the gatherer list +# the note under "Urgent Upgrade Notes". +# +# Exits 0 if the block is valid, 1 otherwise. +# +# Inputs (env vars): +# PR_BODY — full PR body text +# PR_TITLE — PR title (optional; skips the title check if unset) +# COMMIT_SUBJECTS — newline-separated commit subjects (optional; skips +# the commit check if unset) +# +# Requires: bash, awk, grep. No network access. + +set -euo pipefail + +PR_BODY="${PR_BODY:-}" +PR_TITLE="${PR_TITLE:-}" +COMMIT_SUBJECTS="${COMMIT_SUBJECTS:-}" + +# Strip carriage returns so CRLF bodies (common after web-UI edits) +# normalize the same way as LF bodies. +PR_BODY="${PR_BODY//$'\r'/}" + +# Extract the first fenced ```release-note block: lines between the +# opening ```release-note fence and the next closing fence. +NOTE=$(awk ' + /^```release-note/ { inblock = 1; next } + inblock && /^```/ { exit } + inblock { print } +' <<<"${PR_BODY}") + +# Trim each line and drop leading/trailing blank lines, so indented or +# padded blocks still validate. +NOTE_TRIMMED=$( + awk ' + { sub(/^[ \t]+/, ""); sub(/[ \t]+$/, ""); print } + ' <<<"${NOTE}" | + awk 'NF { started = 1 } started { print }' | + awk '{ lines[NR] = $0; last = NR } END { for (i = 1; i <= last; i++) print lines[i] }' +) + +if [[ -z "${NOTE_TRIMMED}" ]]; then + echo "::error::PR body has no release-note block, or the block is empty. Add a fenced \`\`\`release-note block; write NONE if users see no change." >&2 + exit 1 +fi + +# A Conventional Commits breaking-change marker: type, optional scope, +# then `!` before the colon, e.g. "feat(harness)!:" or "fix!:". +BREAKING_RE='^[[:alpha:]]+(\([^)]*\))?!:' + +has_breaking_marker() { + local text="$1" + [[ -z "${text}" ]] && return 1 + grep -Eq "${BREAKING_RE}" <<<"${text}" +} + +# The whole trimmed block must be the unquoted sentinel (case-insensitive) +# for the gatherer to treat it as "no note". This mirrors the gatherer's +# exclusion regex for `none`, `n/a` and `na`. Quoted sentinels ("NONE") +# are NOT excluded by the gatherer — it would publish the literal text — +# so they are rejected below instead. +is_none_block() { + grep -Eiq '^(none|n/a|na)$' <<<"${NOTE_TRIMMED}" +} + +# A quoted sentinel would be published literally by the gatherer. +is_quoted_none_block() { + grep -Eiq "^['\"](none|n/a/na)['\"]$" <<<"${NOTE_TRIMMED}" +} + +# The gatherer drops a PR entirely when its body matches either exclusion +# filter, regardless of which block comes first. Mirror both so a breaking +# PR cannot hide its warning behind a second NONE block or the +# /release-note-none tag. Newlines are folded to spaces first because the +# fenced-block regex spans lines and grep is line-based. +matches_exclusion_filter() { + local oneline + oneline=$(tr '\n' ' ' <<<"${PR_BODY}") + grep -Eiq '```release-notes?[[:space:]]*(none|n/a|na)[[:space:]]*```' <<<"${oneline}" || + grep -q '/release-note-none' <<<"${PR_BODY}" +} + +FIRST_LINE=$(head -n1 <<<"${NOTE_TRIMMED}") + +if is_quoted_none_block; then + echo "::error::release-note block is a quoted sentinel (\"NONE\", 'n/a', ...). The release-notes gatherer publishes quoted text literally; write NONE without quotes." >&2 + exit 1 +fi + +if has_breaking_marker "${PR_TITLE}" || has_breaking_marker "${COMMIT_SUBJECTS}"; then + if is_none_block || matches_exclusion_filter; then + echo "::error::release-note block says NONE (or the body carries a release-note-none marker), but the PR title or a commit subject carries the '!' breaking-change marker. Start the block with 'action required' and describe what breaks." >&2 + exit 1 + fi + if ! grep -Eiq '^action required' <<<"${FIRST_LINE}"; then + echo "::error::PR title or a commit subject carries the '!' breaking-change marker, but the release-note block does not start with 'action required'. Start the block with 'action required' and describe what breaks." >&2 + exit 1 + fi +else + # The gatherer drops a PR entirely when its body matches an exclusion + # filter, regardless of which block comes first. A real note plus a + # leftover NONE block would pass here but never be published, so fail + # instead. + if ! is_none_block && matches_exclusion_filter; then + echo "::error::PR body contains both a release note and a NONE/release-note-none marker; keep exactly one block." >&2 + exit 1 + fi +fi + +echo "release-note block OK" +# Label the PR whenever the accepted note starts with "action required", +# matching COMMITS.md: the block content drives the Urgent label. +if grep -Eiq '^action required' <<<"${FIRST_LINE}"; then + echo "release-note: action-required" + if [[ -n "${GITHUB_OUTPUT:-}" ]]; then + echo "action-required=1" >> "${GITHUB_OUTPUT}" + fi +fi diff --git a/skills/cutting-releases/SKILL.md b/skills/cutting-releases/SKILL.md index d2906ec61b..05fd1767c5 100644 --- a/skills/cutting-releases/SKILL.md +++ b/skills/cutting-releases/SKILL.md @@ -10,8 +10,9 @@ allowed-tools: Read, Grep, Glob, AskUserQuestion, Agent, Bash(git tag:*), Bash(g # Cutting Releases Releases are driven by annotated git tags. When a tag matching `v*` is pushed, -`.github/workflows/release.yml` runs GoReleaser to build binaries, generate a -changelog, and create the GitHub release. +`.github/workflows/release.yml` gathers release notes from `release-note` +blocks in PR bodies, runs GoReleaser to build binaries, and publishes the +GitHub release with the gathered notes. ## Process @@ -80,7 +81,9 @@ git log --oneline ..HEAD ``` Summarize changes into categories (features, fixes, refactors). Exclude -`docs:`, `test:`, `chore:`, `ci:`, `build:`, `style:` commits — GoReleaser filters these anyway. +`docs:`, `test:`, `chore:`, `ci:`, `build:`, `style:` commits — their +release-note blocks typically say NONE, so they do not reach the release +notes. ### 6. Create the RC tag @@ -286,12 +289,16 @@ installs the binary as `fullsend-` so multiple versions can coexist. - **Never delete a tag that published binaries or a GitHub Release.** If a shipped release is bad, cut a new patch or RC. Only a blocked final may be deleted (see "When a release run fails"). -- **The changelog** is auto-generated from commit subjects (which must follow - conventional commit format). GoReleaser uses `changelog.use: github` in - `.goreleaser.yml`, which lists every commit in the release range, so - individual commit subjects — not PR titles — are the source of release-note - entries. PRs land as merge commits, which are excluded, so PR titles never - appear. Subjects with `!` are grouped first under **Breaking Changes**. +- **The changelog** is gathered from `release-note` blocks in merged PR + bodies (see COMMITS.md, "Release notes"). The release workflow runs the + Kubernetes `release-notes` tool over the tag range and passes the + result to GoReleaser via `--release-notes`, so PR bodies — not commit + subjects — are the source of release-note entries. NONE blocks are + skipped. The published body starts with a `## Changelog` header + (prepended by the workflow so `prepend-release-highlights.sh` keeps + working), followed by **Urgent Upgrade Notes** (PRs labeled + `release-note-action-required`, applied automatically when a PR's + block starts with `action required`) and **Changes by Kind**. - **The `v0` tag** is a moving tag consumed by downstream orgs for reusable workflows. It is automatically moved by the release workflow after GoReleaser completes (skipped for pre-release tags). diff --git a/skills/cutting-releases/post-flight.md b/skills/cutting-releases/post-flight.md index 110a64bd62..7c06be025c 100644 --- a/skills/cutting-releases/post-flight.md +++ b/skills/cutting-releases/post-flight.md @@ -29,8 +29,8 @@ gh release view ``` Check that the title, changelog, and binary assets look correct. Breaking -commits (`!` in the subject) should be listed first under **Breaking -Changes**. +changes (PRs whose release-note block starts with `action required`) +should be listed under **Urgent Upgrade Notes**. Verify the release is not marked as a draft. ## B2. Verify agents validation and tag From 7438c46d8beb86c9bbfeb9fb619103eb3a3467d2 Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Tue, 24 Nov 2026 08:14:11 +0100 Subject: [PATCH 2/9] fix(release): harden release-note validator and label sync Fix review findings on the release-note check: - Fix the quoted-sentinel regex typo (n/a/na -> n/a|na) so quoted "n/a" and 'na' blocks are rejected instead of published literally. - Match the whole trimmed block for NONE sentinels instead of any single line. - Require an exact ```release-note fence line; reject malformed fence variants (trailing spaces, release-note-foo) that the gatherer silently skips, and let an indented closing fence close the block. - Fail the label-sync step when an action-required note cannot be labeled (fork PRs with a read-only token) so a maintainer must add the release-note-action-required label before merge; document this in COMMITS.md and CONTRIBUTING.md. - Drop the unused issues: write permission and the stdout action-required sentinel; use GITHUB_OUTPUT only. Assisted-By: Claude Sonnet 4.5 (pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 18 ++-- COMMITS.md | 2 + CONTRIBUTING.md | 4 +- scripts/check-release-note-test.sh | 100 +++++++++++++++++++++-- scripts/check-release-note.sh | 36 +++++--- 5 files changed, 136 insertions(+), 24 deletions(-) diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index b4acc07abf..15215716fb 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -9,7 +9,6 @@ on: permissions: contents: read pull-requests: write - issues: write concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -75,15 +74,20 @@ jobs: ACTION_REQUIRED: ${{ steps.check.outputs.action-required }} run: | set -euo pipefail - # Best-effort: fork PRs run with a read-only token and cannot - # create or add labels. The check itself already passed; do not - # fail valid fork PRs here. + # Fork PRs run with a read-only token and cannot create or add + # labels. For an action-required note that must not be silent: + # without the label the gatherer publishes the note as an + # ordinary bullet and strips the "action required:" prefix, + # losing the Urgent Upgrade Notes entry. Fail instead, so a + # maintainer must add the label before merge. if [[ "${ACTION_REQUIRED:-}" == "1" ]]; then gh label create release-note-action-required --color b60205 \ --description "Release-note block starts with 'action required'" --force \ - || echo "::warning::could not create label (fork PR?)" - gh pr edit "${PR_NUMBER}" --add-label release-note-action-required \ - || echo "::warning::could not add label (fork PR?)" + || echo "::warning::could not create label (it may already exist)" + if ! gh pr edit "${PR_NUMBER}" --add-label release-note-action-required; then + echo "::error::This PR needs the release-note-action-required label (its release-note block starts with 'action required'), but the label could not be added (fork PR with a read-only token). A maintainer must add it before merge." + exit 1 + fi else # Fails if the label is absent; that is the common case. gh pr edit "${PR_NUMBER}" --remove-label release-note-action-required || true diff --git a/COMMITS.md b/COMMITS.md index 1f5972570b..663df4d2b0 100644 --- a/COMMITS.md +++ b/COMMITS.md @@ -99,6 +99,8 @@ The release-note block is what users see. When the block starts with `release-note-action-required`, and the release pipeline lists the note under **Urgent Upgrade Notes** in the published release notes (the gatherer strips the `action required:` prefix from the note text itself). +Fork PRs run with a read-only token, so CI cannot label them; the check +fails instead until a maintainer adds the label. The `!` marker stays required for reviewers and tooling. CI rejects a `NONE` release-note block — and any block that does not start with `action required` — when the PR title or any commit subject carries the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 97991dc415..713dad1d53 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,7 +53,9 @@ contribution. `release-note-action-required` so the note is listed under **Urgent Upgrade Notes** in the release, and CI rejects a `NONE` block (or any block without the prefix) on a PR that carries the `!` marker, so a - breaking change cannot ship without a warning. See + breaking change cannot ship without a warning. Fork PRs cannot be + labeled by CI (read-only token); a maintainer must add the label + before merge. See [COMMITS.md](COMMITS.md#breaking-changes) for how to identify breaking changes and what to include in the commit body. - Wrap prose in Markdown files at about 80 columns, so diffs show only the diff --git a/scripts/check-release-note-test.sh b/scripts/check-release-note-test.sh index 65692cc197..05a574d398 100755 --- a/scripts/check-release-note-test.sh +++ b/scripts/check-release-note-test.sh @@ -27,19 +27,25 @@ run_case() { fi } -# Like run_case, but also asserts on the script's stdout: whether the -# "release-note: action-required" marker is present. That marker drives -# the release-note-action-required label, which is the only way a note +# Like run_case, but also asserts on the script's GITHUB_OUTPUT: whether +# the action-required=1 output is present. That output drives the +# release-note-action-required label, which is the only way a note # lands under Urgent Upgrade Notes. run_marker_case() { local desc="$1" expected_exit="$2" expected_marker="$3" shift 3 local actual_exit actual_marker="absent" local out - out=$("$@" bash "${SCRIPT}" 2>/dev/null) && actual_exit="pass" || actual_exit="fail" - if grep -qx 'release-note: action-required' <<<"${out}"; then + out=$(mktemp) + if GITHUB_OUTPUT="${out}" "$@" bash "${SCRIPT}" >/dev/null 2>&1; then + actual_exit="pass" + else + actual_exit="fail" + fi + if grep -qx 'action-required=1' "${out}"; then actual_marker="present" fi + rm -f "${out}" if [[ "${actual_exit}" == "${expected_exit}" && "${actual_marker}" == "${expected_marker}" ]]; then echo "ok — ${desc}" else @@ -116,6 +122,68 @@ BODY_QUOTED_NONE="## Summary \`\`\` " +BODY_QUOTED_NA="## Summary + +\`\`\`release-note +\"n/a\" +\`\`\` +" + +BODY_QUOTED_NA_LOWER="## Summary + +\`\`\`release-note +'na' +\`\`\` +" + +BODY_QUOTED_NONE_UPPER="## Summary + +\`\`\`release-note +'NONE' +\`\`\` +" + +BODY_NONE_THEN_ACTION_REQUIRED="## Summary + +\`\`\`release-note +NONE +action required: the widget flag is now required. +\`\`\` +" + +BODY_NOTE_WITH_NA_LINE_PLUS_NONE="## Summary + +\`\`\`release-note +Fixed foo. +na +\`\`\` + +\`\`\`release-note +NONE +\`\`\` +" + +# A fence line with real trailing spaces (web editors add them), built at +# runtime so the file itself carries no trailing whitespace for +# pre-commit to strip. +BODY_FENCE_TRAILING_SPACES=$(sed 's/^```release-note$/```release-note /' <<<"${BODY_WITH_NOTE}") + +BODY_FENCE_VARIANT="## Summary + +\`\`\`release-note-foo +Fixed foo. +\`\`\` +" + +BODY_INDENTED_CLOSING_FENCE="## Summary + +\`\`\`release-note +Fixed foo. + \`\`\` + +## Later section +" + BODY_ACTION_REQUIRED_MIXED_CASE="## Summary \`\`\`release-note @@ -201,6 +269,19 @@ run_case "NONE plus extra lines passes (published as a note)" pass \ # Quoted sentinels are rejected: the gatherer publishes quoted text # literally instead of treating it as "no note". run_case "quoted NONE fails (write NONE without quotes)" fail env PR_BODY="$BODY_QUOTED_NONE" +run_case "quoted n/a fails" fail env PR_BODY="$BODY_QUOTED_NA" +run_case "quoted na fails" fail env PR_BODY="$BODY_QUOTED_NA_LOWER" +run_case "quoted 'NONE' (mixed case) fails" fail env PR_BODY="$BODY_QUOTED_NONE_UPPER" + +# Malformed fences are rejected: the gatherer would silently skip them, +# so the note would never be published. +run_case "fence with trailing spaces fails" fail env PR_BODY="$BODY_FENCE_TRAILING_SPACES" +run_case "release-note-foo fence fails" fail env PR_BODY="$BODY_FENCE_VARIANT" + +# An indented closing fence must close the block, not swallow the rest +# of the PR body. +run_case "indented closing fence passes and stops at the fence" pass \ + env PR_BODY="$BODY_INDENTED_CLOSING_FENCE" # Missing or empty blocks fail. run_case "no block fails" fail env PR_BODY="$BODY_NO_BLOCK" @@ -231,6 +312,13 @@ run_case "/release-note-none tag with breaking title fails" fail \ run_case "CRLF NONE with breaking title fails" fail \ env PR_BODY="$BODY_CRLF_NONE" PR_TITLE="$BREAKING_TITLE" +# is_none_block must match the whole block, not any single line: a +# NONE line followed by more content is a real note, not a sentinel. +run_case "NONE then action-required line with breaking title fails (not a NONE block)" fail \ + env PR_BODY="$BODY_NONE_THEN_ACTION_REQUIRED" PR_TITLE="$BREAKING_TITLE" +run_case "note with an na line plus leftover NONE block fails" fail \ + env PR_BODY="$BODY_NOTE_WITH_NA_LINE_PLUS_NONE" PR_TITLE="feat(harness): add thing" + # A real note plus a leftover NONE block fails even without a breaking # marker: the gatherer would drop the whole PR and the note would never # be published. @@ -255,7 +343,7 @@ run_case "breaking commit subject with action required note passes" pass \ run_case "action required in mixed case with breaking title passes" pass \ env PR_BODY="$BODY_ACTION_REQUIRED_MIXED_CASE" PR_TITLE="$BREAKING_TITLE" -# The action-required stdout marker drives the Urgent label. It must be +# The action-required GITHUB_OUTPUT drives the Urgent label. It must be # present for a valid breaking PR and for any accepted note that starts # with "action required", and absent otherwise. run_marker_case "breaking PR emits action-required marker" pass present \ diff --git a/scripts/check-release-note.sh b/scripts/check-release-note.sh index 11fb6f342b..e68ea95ac1 100755 --- a/scripts/check-release-note.sh +++ b/scripts/check-release-note.sh @@ -12,10 +12,10 @@ # "action required". A NONE block (or any of the variants the # release-notes gatherer treats as "no note") is rejected instead. # -# On success the script prints "release-note block OK", plus the line -# "release-note: action-required" when the accepted note starts with -# "action required" (and appends action-required=1 to $GITHUB_OUTPUT when -# set). The release-note-check workflow uses that to label the PR +# On success the script prints "release-note block OK" and, when the +# accepted note starts with "action required", appends +# action-required=1 to $GITHUB_OUTPUT (when set). The release-note-check +# workflow uses that to label the PR # `release-note-action-required`, which is what makes the gatherer list # the note under "Urgent Upgrade Notes". # @@ -40,10 +40,16 @@ COMMIT_SUBJECTS="${COMMIT_SUBJECTS:-}" PR_BODY="${PR_BODY//$'\r'/}" # Extract the first fenced ```release-note block: lines between the -# opening ```release-note fence and the next closing fence. +# opening ```release-note fence and the next closing fence. The opener +# must be exactly ```release-note (or ```release-notes) at column 0: +# the release-notes gatherer only recognizes those exact fence lines, +# so variants like "```release-note " (trailing space) or +# "```release-note-foo" would pass here but be silently skipped by the +# gatherer. They are rejected below instead. The closing fence may be +# indented; NOTE_TRIMMED strips indentation anyway. NOTE=$(awk ' - /^```release-note/ { inblock = 1; next } - inblock && /^```/ { exit } + /^```release-notes?$/ { inblock = 1; next } + inblock && /^[ \t]*```/ { exit } inblock { print } ' <<<"${PR_BODY}") @@ -57,6 +63,16 @@ NOTE_TRIMMED=$( awk '{ lines[NR] = $0; last = NR } END { for (i = 1; i <= last; i++) print lines[i] }' ) +# A fence line that starts like a release-note fence but is not exactly +# ```release-note (or ```release-notes) is accepted by no tool: the +# gatherer skips it, so the note would never be published. Reject it +# with a clear error instead of passing silently. +if grep -Eq '^```release-note' <<<"${PR_BODY}" \ + && ! grep -Eq '^```release-notes?$' <<<"${PR_BODY}"; then + echo "::error::PR body has a malformed release-note fence (e.g. trailing spaces or \`\`\`release-note-foo). The fence line must be exactly \`\`\`release-note." >&2 + exit 1 +fi + if [[ -z "${NOTE_TRIMMED}" ]]; then echo "::error::PR body has no release-note block, or the block is empty. Add a fenced \`\`\`release-note block; write NONE if users see no change." >&2 exit 1 @@ -78,12 +94,13 @@ has_breaking_marker() { # are NOT excluded by the gatherer — it would publish the literal text — # so they are rejected below instead. is_none_block() { - grep -Eiq '^(none|n/a|na)$' <<<"${NOTE_TRIMMED}" + [[ "${NOTE_TRIMMED,,}" =~ ^(none|n/a|na)$ ]] } # A quoted sentinel would be published literally by the gatherer. is_quoted_none_block() { - grep -Eiq "^['\"](none|n/a/na)['\"]$" <<<"${NOTE_TRIMMED}" + local re="^['\"](none|n/a|na)['\"]$" + [[ "${NOTE_TRIMMED,,}" =~ ${re} ]] } # The gatherer drops a PR entirely when its body matches either exclusion @@ -129,7 +146,6 @@ echo "release-note block OK" # Label the PR whenever the accepted note starts with "action required", # matching COMMITS.md: the block content drives the Urgent label. if grep -Eiq '^action required' <<<"${FIRST_LINE}"; then - echo "release-note: action-required" if [[ -n "${GITHUB_OUTPUT:-}" ]]; then echo "action-required=1" >> "${GITHUB_OUTPUT}" fi From 30db0a92f8dee93f6dc934d98fe0a2fdcb0cecbb Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 25 Nov 2026 08:37:54 +0100 Subject: [PATCH 3/9] ci(release): filter gathered PRs to the tag range and render grouped notes The release-notes gatherer credits a commit to any PR cited as "(#N)" in its message, so notes from PRs in earlier releases could be republished. Gather as JSON and render with a new script, scripts/render-release-notes.sh, which keeps only PRs merged in the first-parent PREV..TAG range and groups notes by PR title type (Urgent Upgrade Notes, Breaking Changes, Features, Bug Fixes, Refactoring, Other Changes), mirroring the old GoReleaser changelog layout instead of the tool's kind-label-based default template. Also fix the release-note-check recovery path for fork PRs: accept an already-present release-note-action-required label without a write, and add the labeled trigger so a maintainer adding the label re-runs the check. Reword the stale 'feat is for end users' rationale in COMMITS.md now that commit prefixes no longer feed release notes. Assisted-By: Claude Sonnet 4.5 (pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 16 +- .github/workflows/release.yml | 26 +++- COMMITS.md | 13 +- Makefile | 1 + scripts/render-release-notes-test.sh | 178 +++++++++++++++++++++++ scripts/render-release-notes.sh | 128 ++++++++++++++++ 6 files changed, 355 insertions(+), 7 deletions(-) create mode 100755 scripts/render-release-notes-test.sh create mode 100755 scripts/render-release-notes.sh diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index 15215716fb..0c2642edec 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -2,7 +2,10 @@ name: Release Note Check on: pull_request: - types: [opened, synchronize, reopened, edited] + # `labeled` is included so the recovery path for fork PRs works: a + # maintainer adding release-note-action-required re-runs this check, + # which then accepts the already-present label without a write. + types: [opened, synchronize, reopened, edited, labeled] branches: [main] merge_group: @@ -79,8 +82,17 @@ jobs: # without the label the gatherer publishes the note as an # ordinary bullet and strips the "action required:" prefix, # losing the Urgent Upgrade Notes entry. Fail instead, so a - # maintainer must add the label before merge. + # maintainer must add the label before merge; the `labeled` + # trigger then re-runs this check, which accepts the label + # without a write. if [[ "${ACTION_REQUIRED:-}" == "1" ]]; then + # Already labeled (e.g. a maintainer added the label on a fork + # PR): accept it without a write — the fork's read-only token + # cannot mutate labels even when the label is present. + if gh pr view "${PR_NUMBER}" --json labels \ + --jq '.labels[].name' | grep -qx release-note-action-required; then + exit 0 + fi gh label create release-note-action-required --color b60205 \ --description "Release-note block starts with 'action required'" --force \ || echo "::warning::could not create label (it may already exist)" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8604869d1b..451648d52e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -121,11 +121,35 @@ jobs: # includes bot-authored PRs (agents open many of our PRs). Write # outside the checkout: GoReleaser refuses a dirty git tree. export BRANCH="${END_SHA}" + # Gather as JSON, then render with our own script. The tool + # credits a commit to any PR cited as "(#N)" in its message, so + # PRs from earlier releases can appear; the renderer keeps only + # PRs actually merged in the range (first-parent commits between + # PREV and TAG) and groups notes by PR title type, mirroring the + # old GoReleaser changelog layout. release-notes generate \ --required-author="" \ --dependencies=false \ - --output "${RUNNER_TEMP}/release-notes-body.md" \ + --format json \ + --output "${RUNNER_TEMP}/release-notes.json" \ --org fullsend-ai --repo fullsend + # PRs merged in this release: merge commits say "Merge pull + # request #N"; squash-merge subjects end with "(#N)". + git log --first-parent --format='%s' "${PREV}..${TAG}" \ + | sed -nE 's/^Merge pull request #([0-9]+).*/\1/p; s/.*\(#([0-9]+)\)$/\1/p' \ + | sort -u > "${RUNNER_TEMP}/merged-prs.txt" + # Titles for the gathered PRs (one cheap API call each; only PRs + # with a release-note block reach this list). + : > "${RUNNER_TEMP}/pr-titles.tsv" + while read -r pr; do + gh pr view "${pr}" --json number,title \ + --jq '"\\(.number)\\t\\(.title)"' >> "${RUNNER_TEMP}/pr-titles.tsv" + done < <(jq -r 'keys[]' "${RUNNER_TEMP}/release-notes.json") + bash scripts/render-release-notes.sh \ + "${RUNNER_TEMP}/release-notes.json" \ + "${RUNNER_TEMP}/merged-prs.txt" \ + "${RUNNER_TEMP}/pr-titles.tsv" \ + > "${RUNNER_TEMP}/release-notes-body.md" # Prepend the header prepend-release-highlights.sh expects, so # the release-highlights step keeps working with the # gathered-notes body. diff --git a/COMMITS.md b/COMMITS.md index 663df4d2b0..2804b04ad3 100644 --- a/COMMITS.md +++ b/COMMITS.md @@ -53,9 +53,11 @@ Add `role: ` to any harness file that lacks it. ## `feat` is for end users -The `feat` prefix marks user-facing functionality. End users read the -release notes to decide whether to upgrade. Reserve `feat` for changes an -end user would recognize as new capability: +Commit types classify git history and are gitlint-enforced; the PR-body +release-note block controls what end users read in the release notes. +The `feat` prefix still marks user-facing functionality, so the history +stays meaningful. Reserve `feat` for changes an end user would recognize +as new capability: - A new CLI command or flag they can invoke - A new behavior they interact with (e.g., the agent now comments on their PR with a new kind of analysis) @@ -71,7 +73,10 @@ end user would recognize as new capability: Apply the same discipline to `fix` — bumping a dependency version is `chore`, not `fix`, unless it corrects a user-visible bug. Removing a trailing blank line is `style`, not `fix`. -**When in doubt, prefer `refactor` or `chore` over `feat` or `fix`.** A change miscategorized as `refactor` is harmless — its release-note block can still say what matters. A change miscategorized as `feat` erodes the signal of the release notes. +**When in doubt, prefer `refactor` or `chore` over `feat` or `fix`.** A +miscategorized type mislabels the git history, not the release notes — +the PR-body release-note block decides what users read — but an honest +history is still worth keeping. ## Scope diff --git a/Makefile b/Makefile index 8b82f05595..001093c44f 100644 --- a/Makefile +++ b/Makefile @@ -188,6 +188,7 @@ endef script-test: $(call run-timed,bash scripts/check-release-note-test.sh) + $(call run-timed,bash scripts/render-release-notes-test.sh) $(call run-timed,bash scripts/check-live-test-relevance-test.sh) $(call run-timed,bash scripts/check-e2e-authorization-test.sh) $(call run-timed,bash scripts/vouch-sweep-test.sh) diff --git a/scripts/render-release-notes-test.sh b/scripts/render-release-notes-test.sh new file mode 100755 index 0000000000..886f320c27 --- /dev/null +++ b/scripts/render-release-notes-test.sh @@ -0,0 +1,178 @@ +#!/usr/bin/env bash +# render-release-notes-test.sh — Tests for render-release-notes.sh +# +# Run from the repo root: +# bash scripts/render-release-notes-test.sh + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT="${SCRIPT_DIR}/render-release-notes.sh" +TMP=$(mktemp -d) +trap 'rm -rf "${TMP}"' EXIT + +FAILURES=0 + +check() { + local desc=$1 expected=$2 actual + actual=$("${SCRIPT}" "${TMP}/notes.json" "${TMP}/merged.txt" "${TMP}/titles.tsv") + if [[ "${actual}" == "${expected}" ]]; then + echo "ok — ${desc}" + else + echo "FAIL — ${desc}" + echo "--- expected ---" + printf '%s\n' "${expected}" + echo "--- actual ---" + printf '%s\n' "${actual}" + FAILURES=$((FAILURES + 1)) + fi +} + +write_fixtures() { + # $1: titles TSV content; stdin: notes JSON. The merged-PR list is + # written separately after each call. + cat >"${TMP}/notes.json" + printf '%b' "$1" >"${TMP}/titles.tsv" +} + +# --- Grouping by PR title type ------------------------------------------- + +write_fixtures '101\tfeat(cli): new thing +102\tfix: a bug +103\trefactor: internals +104\tdocs: some docs +105\tfeat(api)!: breaking change +' <<'EOF' +{ + "101": {"pr_number": 101, "markdown": "Adds a new CLI flag.", "text": "", + "pr_url": "https://example.com/pull/101", "author": "alice", + "author_url": "https://example.com/alice"}, + "102": {"pr_number": 102, "markdown": "Fixes a crash.", "text": "", + "pr_url": "https://example.com/pull/102", "author": "bob", + "author_url": "https://example.com/bob"}, + "103": {"pr_number": 103, "markdown": "Renames a package.", "text": "", + "pr_url": "https://example.com/pull/103", "author": "carol", + "author_url": "https://example.com/carol"}, + "104": {"pr_number": 104, "markdown": "Documents a flag.", "text": "", + "pr_url": "https://example.com/pull/104", "author": "dave", + "author_url": "https://example.com/dave"}, + "105": {"pr_number": 105, "markdown": "Removes a flag.", "text": "", + "pr_url": "https://example.com/pull/105", "author": "erin", + "author_url": "https://example.com/erin"} +} +EOF +cat >"${TMP}/merged.txt" <<'EOF' +101 +102 +103 +104 +105 +EOF + +check "notes grouped by title type" '### Breaking Changes + +- Removes a flag. ([#105](https://example.com/pull/105), [@erin](https://example.com/erin)) + +### Features + +- Adds a new CLI flag. ([#101](https://example.com/pull/101), [@alice](https://example.com/alice)) + +### Bug Fixes + +- Fixes a crash. ([#102](https://example.com/pull/102), [@bob](https://example.com/bob)) + +### Refactoring + +- Renames a package. ([#103](https://example.com/pull/103), [@carol](https://example.com/carol)) + +### Other Changes + +- Documents a flag. ([#104](https://example.com/pull/104), [@dave](https://example.com/dave))' + +# --- PRs outside the merged set are dropped ------------------------------ + +write_fixtures '101\tfeat(cli): new thing +' <<'EOF' +{ + "101": {"pr_number": 101, "markdown": "Adds a new CLI flag.", "text": "", + "pr_url": "https://example.com/pull/101", "author": "alice", + "author_url": "https://example.com/alice"}, + "999": {"pr_number": 999, "markdown": "Old release note.", "text": "", + "pr_url": "https://example.com/pull/999", "author": "mallory", + "author_url": "https://example.com/mallory"} +} +EOF +cat >"${TMP}/merged.txt" <<'EOF' +101 +EOF + +check "PR cited in a commit body but not merged in range is dropped" '### Features + +- Adds a new CLI flag. ([#101](https://example.com/pull/101), [@alice](https://example.com/alice))' + +# --- Action-required notes and do-not-publish ---------------------------- + +write_fixtures '201\tfix: urgent thing +202\tfeat: quiet thing +' <<'EOF' +{ + "201": {"pr_number": 201, "markdown": "The role field is now required.", "text": "", + "pr_url": "https://example.com/pull/201", "author": "alice", + "author_url": "https://example.com/alice", "action_required": true}, + "202": {"pr_number": 202, "markdown": "Should not appear.", "text": "", + "pr_url": "https://example.com/pull/202", "author": "bob", + "author_url": "https://example.com/bob", "do_not_publish": true} +} +EOF +cat >"${TMP}/merged.txt" <<'EOF' +201 +202 +EOF + +check "action-required note lands under Urgent Upgrade Notes; do-not-publish dropped" '## Urgent Upgrade Notes + +- The role field is now required. ([#201](https://example.com/pull/201), [@alice](https://example.com/alice))' + +# --- Multi-line notes stay inside the bullet ----------------------------- + +write_fixtures '301\tfeat: multi-line +' <<'EOF' +{ + "301": {"pr_number": 301, "markdown": "First line.\nSecond line.", "text": "", + "pr_url": "https://example.com/pull/301", "author": "alice", + "author_url": "https://example.com/alice"} +} +EOF +cat >"${TMP}/merged.txt" <<'EOF' +301 +EOF + +check "multi-line note continuation lines are indented" '### Features + +- First line. + Second line. ([#301](https://example.com/pull/301), [@alice](https://example.com/alice))' + +# --- Empty input ---------------------------------------------------------- + +write_fixtures '401\tfeat: nothing +' <<'EOF' +{} +EOF +: >"${TMP}/merged.txt" + +check "empty notes render an empty body" '' + +# --- Missing files -------------------------------------------------------- + +if "${SCRIPT}" "${TMP}/missing.json" "${TMP}/merged.txt" "${TMP}/titles.tsv" 2>/dev/null; then + echo "FAIL — missing notes file should be an error" + FAILURES=$((FAILURES + 1)) +else + echo "ok — missing notes file is an error" +fi + +if [[ ${FAILURES} -gt 0 ]]; then + echo "${FAILURES} test(s) failed" + exit 1 +fi +echo "all tests passed" diff --git a/scripts/render-release-notes.sh b/scripts/render-release-notes.sh new file mode 100755 index 0000000000..c8a8fc857b --- /dev/null +++ b/scripts/render-release-notes.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +# render-release-notes.sh — Render release notes from the Kubernetes +# release-notes tool's JSON output. +# +# The gatherer can credit a commit to any PR cited as "(#N)" in its +# message, so its JSON may contain PRs from earlier releases. This script +# keeps only PRs that were actually merged in the tag range (the caller +# passes their numbers) and groups the notes by PR title type, mirroring +# the layout the old GoReleaser changelog used. +# +# Usage: +# render-release-notes.sh NOTES_JSON MERGED_PRS TITLES_TSV +# +# NOTES_JSON --output file of `release-notes generate --format json` +# (an object keyed by PR number). +# MERGED_PRS file with one PR number per line: the PRs merged in the +# tag range (first-parent commits between the tags). +# TITLES_TSV file with `NUMBERTITLE` lines (PR titles; used to +# pick the section for each note). +# +# Prints the markdown body (without the `## Changelog` header, which the +# release workflow prepends) to stdout. + +set -euo pipefail + +if [[ $# -ne 3 ]]; then + echo "usage: $0 NOTES_JSON MERGED_PRS TITLES_TSV" >&2 + exit 2 +fi + +NOTES_JSON=$1 +MERGED_PRS=$2 +TITLES_TSV=$3 + +for f in "${NOTES_JSON}" "${MERGED_PRS}" "${TITLES_TSV}"; do + if [[ ! -f "${f}" ]]; then + echo "error: file not found: ${f}" >&2 + exit 2 + fi +done + +# jq arguments: the allowed PR numbers and the PR titles. +ALLOWED=$(jq -Rn '[inputs | tonumber]' "${MERGED_PRS}") +TITLES=$(jq -Rn ' + reduce inputs as $line ({}; + ($line | split("\t")) as $parts + | .[$parts[0]] = ($parts[1] // "") + )' "${TITLES_TSV}") + +# One JSON object per line for each published note: number, title, +# text, PR URL, author, author URL, action-required flag. Notes for PRs +# outside the merged set, notes marked do-not-publish, and empty notes +# are dropped here. +ROWS=$(jq -c --argjson allowed "${ALLOWED}" --argjson titles "${TITLES}" ' + [ to_entries[] + | select(.value.pr_number as $n | $allowed | index($n)) + | select(.value.do_not_publish != true) + | .value + | select((.markdown // .text | length) > 0) + | {number: .pr_number, title: ($titles[.pr_number | tostring] // ""), + text: (.markdown // .text), url: .pr_url, + author: .author, author_url: .author_url, + action_required: (.action_required == true)} + ] | sort_by(.number) | .[]' "${NOTES_JSON}") + +# Section for a note, in priority order. Action-required notes always go +# under Urgent Upgrade Notes; otherwise the PR title type decides, with +# `!` (breaking) pulled out of the type groups first — same order the old +# GoReleaser changelog used. +# Regexes in variables: bash cannot parse nested parentheses in an +# inline `[[ =~ ]]` pattern. +RE_BREAKING='^[a-z]+(\([^)]*\))?!:' +RE_FEAT='^feat(\([^)]*\))?!?:' +RE_FIX='^fix(\([^)]*\))?!?:' +RE_REFACTOR='^refactor(\([^)]*\))?!?:' + +section_for() { + local number=$1 action_required=$2 title=$3 + if [[ "${action_required}" == "true" ]]; then + echo "urgent" + elif [[ "${title}" =~ ${RE_BREAKING} ]]; then + echo "breaking" + elif [[ "${title}" =~ ${RE_FEAT} ]]; then + echo "features" + elif [[ "${title}" =~ ${RE_FIX} ]]; then + echo "fixes" + elif [[ "${title}" =~ ${RE_REFACTOR} ]]; then + echo "refactoring" + else + echo "other" + fi +} + +declare -a SECTIONS=(urgent breaking features fixes refactoring other) +declare -A HEADINGS=( + [urgent]="## Urgent Upgrade Notes" + [breaking]="### Breaking Changes" + [features]="### Features" + [fixes]="### Bug Fixes" + [refactoring]="### Refactoring" + [other]="### Other Changes" +) +declare -A BULLETS + +while IFS= read -r line; do + [[ -z "${line}" ]] && continue + number=$(jq -r .number <<<"${line}") + title=$(jq -r .title <<<"${line}") + text=$(jq -r .text <<<"${line}") + url=$(jq -r .url <<<"${line}") + author=$(jq -r .author <<<"${line}") + author_url=$(jq -r .author_url <<<"${line}") + action_required=$(jq -r '.action_required' <<<"${line}") + section=$(section_for "${number}" "${action_required}" "${title}") + # Indent continuation lines of multi-line notes so they stay inside the + # bullet. + formatted=$(printf '%s\n' "${text}" | sed '2,$s/^/ /') + BULLETS[${section}]+="- ${formatted} ([#${number}](${url}), [@${author}](${author_url}))"$'\n' +done <<<"${ROWS}" + +for section in "${SECTIONS[@]}"; do + if [[ -n "${BULLETS[${section}]:-}" ]]; then + echo "${HEADINGS[${section}]}" + echo + printf '%s' "${BULLETS[${section}]}" + echo + fi +done From c957320d0b0cc624ee64183a7de0f1438eaab7bd Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 25 Nov 2026 11:15:10 +0100 Subject: [PATCH 4/9] fix(release): address review findings in release-notes tooling - release.yml: unescape the jq expression so the PR-titles TSV gets real numbers and titles instead of literal interpolation text - render-release-notes.sh: build bullets from the gatherer's text field; its markdown field already carries PR/author attribution and indented continuation lines, which would be duplicated - check-release-note.sh: require an unindented closing fence and reject unterminated blocks, matching what the gatherer recognizes - release-note-check.yml: scope pull-requests: write to the job so checkout and validation run read-only - render-release-notes.sh: drop the unused number parameter from section_for Assisted-By: claude-sonnet-4-5(pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 6 ++- .github/workflows/release.yml | 2 +- scripts/check-release-note-test.sh | 16 ++++++-- scripts/check-release-note.sh | 22 ++++++----- scripts/render-release-notes-test.sh | 47 +++++++++++++++++++----- scripts/render-release-notes.sh | 8 ++-- 6 files changed, 73 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index 0c2642edec..43a3263af3 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -11,7 +11,6 @@ on: permissions: contents: read - pull-requests: write concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -25,6 +24,11 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-24.04 timeout-minutes: 5 + # Only the label-sync step needs to write; keep that grant at job + # level so checkout and validation run read-only. + permissions: + contents: read + pull-requests: write steps: # Check out the PR's base ref, not the PR head: the validator must # come from a trusted revision so a PR cannot neuter its own check diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 451648d52e..95725a5742 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -143,7 +143,7 @@ jobs: : > "${RUNNER_TEMP}/pr-titles.tsv" while read -r pr; do gh pr view "${pr}" --json number,title \ - --jq '"\\(.number)\\t\\(.title)"' >> "${RUNNER_TEMP}/pr-titles.tsv" + --jq '"\(.number)\t\(.title)"' >> "${RUNNER_TEMP}/pr-titles.tsv" done < <(jq -r 'keys[]' "${RUNNER_TEMP}/release-notes.json") bash scripts/render-release-notes.sh \ "${RUNNER_TEMP}/release-notes.json" \ diff --git a/scripts/check-release-note-test.sh b/scripts/check-release-note-test.sh index 05a574d398..0e9b473347 100755 --- a/scripts/check-release-note-test.sh +++ b/scripts/check-release-note-test.sh @@ -278,10 +278,20 @@ run_case "quoted 'NONE' (mixed case) fails" fail env PR_BODY="$BODY_QUOTED_NONE_ run_case "fence with trailing spaces fails" fail env PR_BODY="$BODY_FENCE_TRAILING_SPACES" run_case "release-note-foo fence fails" fail env PR_BODY="$BODY_FENCE_VARIANT" -# An indented closing fence must close the block, not swallow the rest -# of the PR body. -run_case "indented closing fence passes and stops at the fence" pass \ +BODY_MISSING_CLOSING_FENCE="## Summary + +\`\`\`release-note +Fixed foo. + +## Later section +" + +# An indented closing fence is not a closer for the gatherer, so such a +# block must fail CI instead of being silently skipped at release. +run_case "indented closing fence fails" fail \ env PR_BODY="$BODY_INDENTED_CLOSING_FENCE" +run_case "missing closing fence fails" fail \ + env PR_BODY="$BODY_MISSING_CLOSING_FENCE" # Missing or empty blocks fail. run_case "no block fails" fail env PR_BODY="$BODY_NO_BLOCK" diff --git a/scripts/check-release-note.sh b/scripts/check-release-note.sh index e68ea95ac1..c9eb2109d7 100755 --- a/scripts/check-release-note.sh +++ b/scripts/check-release-note.sh @@ -40,18 +40,22 @@ COMMIT_SUBJECTS="${COMMIT_SUBJECTS:-}" PR_BODY="${PR_BODY//$'\r'/}" # Extract the first fenced ```release-note block: lines between the -# opening ```release-note fence and the next closing fence. The opener -# must be exactly ```release-note (or ```release-notes) at column 0: -# the release-notes gatherer only recognizes those exact fence lines, -# so variants like "```release-note " (trailing space) or -# "```release-note-foo" would pass here but be silently skipped by the -# gatherer. They are rejected below instead. The closing fence may be -# indented; NOTE_TRIMMED strips indentation anyway. +# opening ```release-note fence and the next closing fence. Both fences +# must be exactly as the release-notes gatherer recognizes them: the +# opener exactly ```release-note (or ```release-notes) at column 0, and +# the closer exactly ``` at column 0 directly after a newline. Variants +# the gatherer would skip or mis-parse (trailing spaces, an indented +# closer, a missing closer) are rejected below instead of passing CI and +# then being silently dropped at release time. NOTE=$(awk ' /^```release-notes?$/ { inblock = 1; next } - inblock && /^[ \t]*```/ { exit } + inblock && /^```$/ { closed = 1; exit } inblock { print } -' <<<"${PR_BODY}") + END { if (inblock && !closed) exit 3 } +' <<<"${PR_BODY}") || { + echo "::error::PR body has a release-note block that is never closed by an unindented fence line. The gatherer would skip or mis-extract it; close the block with a fence line (three backticks) at column 0." >&2 + exit 1 +} # Trim each line and drop leading/trailing blank lines, so indented or # padded blocks still validate. diff --git a/scripts/render-release-notes-test.sh b/scripts/render-release-notes-test.sh index 886f320c27..281e76f48c 100755 --- a/scripts/render-release-notes-test.sh +++ b/scripts/render-release-notes-test.sh @@ -44,19 +44,24 @@ write_fixtures '101\tfeat(cli): new thing 105\tfeat(api)!: breaking change ' <<'EOF' { - "101": {"pr_number": 101, "markdown": "Adds a new CLI flag.", "text": "", + "101": {"pr_number": 101, "text": "Adds a new CLI flag.", + "markdown": "Adds a new CLI flag. ([#101](https://example.com/pull/101), [@alice](https://example.com/alice))", "pr_url": "https://example.com/pull/101", "author": "alice", "author_url": "https://example.com/alice"}, - "102": {"pr_number": 102, "markdown": "Fixes a crash.", "text": "", + "102": {"pr_number": 102, "text": "Fixes a crash.", + "markdown": "Fixes a crash. ([#102](https://example.com/pull/102), [@bob](https://example.com/bob))", "pr_url": "https://example.com/pull/102", "author": "bob", "author_url": "https://example.com/bob"}, - "103": {"pr_number": 103, "markdown": "Renames a package.", "text": "", + "103": {"pr_number": 103, "text": "Renames a package.", + "markdown": "Renames a package. ([#103](https://example.com/pull/103), [@carol](https://example.com/carol))", "pr_url": "https://example.com/pull/103", "author": "carol", "author_url": "https://example.com/carol"}, - "104": {"pr_number": 104, "markdown": "Documents a flag.", "text": "", + "104": {"pr_number": 104, "text": "Documents a flag.", + "markdown": "Documents a flag. ([#104](https://example.com/pull/104), [@dave](https://example.com/dave))", "pr_url": "https://example.com/pull/104", "author": "dave", "author_url": "https://example.com/dave"}, - "105": {"pr_number": 105, "markdown": "Removes a flag.", "text": "", + "105": {"pr_number": 105, "text": "Removes a flag.", + "markdown": "Removes a flag. ([#105](https://example.com/pull/105), [@erin](https://example.com/erin))", "pr_url": "https://example.com/pull/105", "author": "erin", "author_url": "https://example.com/erin"} } @@ -94,10 +99,10 @@ check "notes grouped by title type" '### Breaking Changes write_fixtures '101\tfeat(cli): new thing ' <<'EOF' { - "101": {"pr_number": 101, "markdown": "Adds a new CLI flag.", "text": "", + "101": {"pr_number": 101, "text": "Adds a new CLI flag.", "pr_url": "https://example.com/pull/101", "author": "alice", "author_url": "https://example.com/alice"}, - "999": {"pr_number": 999, "markdown": "Old release note.", "text": "", + "999": {"pr_number": 999, "text": "Old release note.", "pr_url": "https://example.com/pull/999", "author": "mallory", "author_url": "https://example.com/mallory"} } @@ -116,10 +121,10 @@ write_fixtures '201\tfix: urgent thing 202\tfeat: quiet thing ' <<'EOF' { - "201": {"pr_number": 201, "markdown": "The role field is now required.", "text": "", + "201": {"pr_number": 201, "text": "The role field is now required.", "pr_url": "https://example.com/pull/201", "author": "alice", "author_url": "https://example.com/alice", "action_required": true}, - "202": {"pr_number": 202, "markdown": "Should not appear.", "text": "", + "202": {"pr_number": 202, "text": "Should not appear.", "pr_url": "https://example.com/pull/202", "author": "bob", "author_url": "https://example.com/bob", "do_not_publish": true} } @@ -138,7 +143,8 @@ check "action-required note lands under Urgent Upgrade Notes; do-not-publish dro write_fixtures '301\tfeat: multi-line ' <<'EOF' { - "301": {"pr_number": 301, "markdown": "First line.\nSecond line.", "text": "", + "301": {"pr_number": 301, "text": "First line.\nSecond line.", + "markdown": "First line.\n Second line. ([#301](https://example.com/pull/301), [@alice](https://example.com/alice))", "pr_url": "https://example.com/pull/301", "author": "alice", "author_url": "https://example.com/alice"} } @@ -152,6 +158,27 @@ check "multi-line note continuation lines are indented" '### Features - First line. Second line. ([#301](https://example.com/pull/301), [@alice](https://example.com/alice))' +# --- Titles TSV produced the way release.yml produces it --------------- + +# release.yml builds the TSV with `gh pr view --json number,title +# --jq '"\(.number)\t\(.title)"'`. gh's --jq is jq, so simulate it with +# jq on the same JSON shape and feed the result to the renderer, so the +# producer and consumer cannot drift apart again. +printf '{"number": 501, "title": "feat: tsv producer"}\n' \ + | jq -r '"\(.number)\t\(.title)"' > "${TMP}/titles.tsv" +cat >"${TMP}/notes.json" <<'EOF' +{ + "501": {"pr_number": 501, "text": "Note from the TSV producer test.", + "pr_url": "https://example.com/pull/501", "author": "alice", + "author_url": "https://example.com/alice"} +} +EOF +printf '501\n' >"${TMP}/merged.txt" + +check "titles TSV built with the workflow's jq expression drives section choice" '### Features + +- Note from the TSV producer test. ([#501](https://example.com/pull/501), [@alice](https://example.com/alice))' + # --- Empty input ---------------------------------------------------------- write_fixtures '401\tfeat: nothing diff --git a/scripts/render-release-notes.sh b/scripts/render-release-notes.sh index c8a8fc857b..38b2841c3d 100755 --- a/scripts/render-release-notes.sh +++ b/scripts/render-release-notes.sh @@ -56,9 +56,9 @@ ROWS=$(jq -c --argjson allowed "${ALLOWED}" --argjson titles "${TITLES}" ' | select(.value.pr_number as $n | $allowed | index($n)) | select(.value.do_not_publish != true) | .value - | select((.markdown // .text | length) > 0) + | select((.text | length) > 0) | {number: .pr_number, title: ($titles[.pr_number | tostring] // ""), - text: (.markdown // .text), url: .pr_url, + text: .text, url: .pr_url, author: .author, author_url: .author_url, action_required: (.action_required == true)} ] | sort_by(.number) | .[]' "${NOTES_JSON}") @@ -75,7 +75,7 @@ RE_FIX='^fix(\([^)]*\))?!?:' RE_REFACTOR='^refactor(\([^)]*\))?!?:' section_for() { - local number=$1 action_required=$2 title=$3 + local action_required=$1 title=$2 if [[ "${action_required}" == "true" ]]; then echo "urgent" elif [[ "${title}" =~ ${RE_BREAKING} ]]; then @@ -111,7 +111,7 @@ while IFS= read -r line; do author=$(jq -r .author <<<"${line}") author_url=$(jq -r .author_url <<<"${line}") action_required=$(jq -r '.action_required' <<<"${line}") - section=$(section_for "${number}" "${action_required}" "${title}") + section=$(section_for "${action_required}" "${title}") # Indent continuation lines of multi-line notes so they stay inside the # bullet. formatted=$(printf '%s\n' "${text}" | sed '2,$s/^/ /') From 54f5321caabd002f23f80d975326dea18a0257ee Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 25 Nov 2026 12:02:10 +0100 Subject: [PATCH 5/9] fix(ci): address release-notes review feedback - release-note-check: trigger on unlabeled so removing release-note-action-required re-runs validation - release-note-check: correct the job-scope permissions comment - check-release-note: hoist the none/n/a/na sentinel into SENTINEL_PAT - release: extract the gather step into scripts/gather-release-notes.sh and add a workflow_dispatch dry-run that measures GITHUB_TOKEN rate limit and runtime over a tag range Assisted-By: Claude Sonnet 4.5 (pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 16 ++- .github/workflows/release.yml | 141 +++++++++++------------ scripts/check-release-note.sh | 11 +- scripts/gather-release-notes.sh | 91 +++++++++++++++ skills/cutting-releases/SKILL.md | 6 + 5 files changed, 184 insertions(+), 81 deletions(-) create mode 100644 scripts/gather-release-notes.sh diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index 43a3263af3..ef6597923c 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -2,10 +2,12 @@ name: Release Note Check on: pull_request: - # `labeled` is included so the recovery path for fork PRs works: a - # maintainer adding release-note-action-required re-runs this check, - # which then accepts the already-present label without a write. - types: [opened, synchronize, reopened, edited, labeled] + # `labeled` and `unlabeled` are included so the recovery path for + # fork PRs works and label removal cannot strand a stale pass: adding + # release-note-action-required re-runs this check (which then accepts + # the already-present label without a write), and removing it re-runs + # validation, which re-adds the label (same-repo) or fails the check. + types: [opened, synchronize, reopened, edited, labeled, unlabeled] branches: [main] merge_group: @@ -24,8 +26,10 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-24.04 timeout-minutes: 5 - # Only the label-sync step needs to write; keep that grant at job - # level so checkout and validation run read-only. + # Note: permissions are granted at job scope, so every step in this + # job — including checkout and validation — runs with a token that can + # write to PRs on same-repo runs (fork tokens are downgraded by + # GitHub). Only the label-sync step below actually writes. permissions: contents: read pull-requests: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 95725a5742..34da2c1fdf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,17 @@ on: push: tags: - "v[0-9]+.[0-9]+.[0-9]+*" + # Dry-run of the release-notes gather step only: measures the + # GITHUB_TOKEN rate-limit cost and runtime over a real tag range + # before a final release relies on it. Nothing is built or published. + workflow_dispatch: + inputs: + start-tag: + description: "Previous tag (gather PRs merged after this tag)" + required: true + end-tag: + description: "Tag to gather notes up to" + required: true permissions: contents: write @@ -11,6 +22,7 @@ permissions: jobs: release: + if: github.event_name == 'push' needs: [validate-agents, resolve-agents, recheck-tag] runs-on: ubuntu-24.04 # pull-requests: read is needed by release-notes generate, which reads @@ -63,20 +75,6 @@ jobs: # reads the blocks from the merged PRs in the tag range, skips NONE # entries, and renders markdown. GoReleaser then publishes that # markdown instead of its commit-subject changelog. - - name: Install release-notes - env: - # SHA-256 of release-notes-amd64-linux from the v0.17.1 release. - # Update the URL and this digest together (see - # scripts/renovate/ for the checksum-pinning convention). - RELEASE_NOTES_SHA256: 16e0ada3e3602c229e97fa789ea97c7d128710d7fe1fee9f12c00f7eaa770d6a - run: | - set -euo pipefail - curl -fsSLo "${RUNNER_TEMP}/release-notes" \ - https://github.com/kubernetes/release/releases/download/v0.17.1/release-notes-amd64-linux - echo "${RELEASE_NOTES_SHA256} ${RUNNER_TEMP}/release-notes" | sha256sum -c - - chmod +x "${RUNNER_TEMP}/release-notes" - sudo mv "${RUNNER_TEMP}/release-notes" /usr/local/bin/release-notes - - name: Generate release notes from PR bodies env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -99,62 +97,11 @@ jobs: echo "::error::Could not find a previous release tag before the current tag" exit 1 fi - echo "Gathering notes from ${PREV} to ${TAG}" - # The tool lists commits from START_SHA's commit date onward - # (inclusive). Use the first first-parent commit after PREV: - # picking the oldest-dated commit in the range would open the - # window before PREV (PR-branch commits can carry dates older - # than PREV) and re-list PRs from the previous release. - RANGE=$(git rev-list --first-parent --reverse "${PREV}..${TAG}") - if [[ -n "${RANGE}" ]]; then - START_SHA=$(head -n1 <<<"${RANGE}") - else - # PREV and TAG share a commit (a re-tag); fall back to PREV. - START_SHA=$(git rev-list -n1 "${PREV}") - fi - END_SHA=$(git rev-list -n1 "${TAG}") - export START_SHA END_SHA - # The tool reads its range and branch from these env vars. Use - # the tag's SHA as the listing ref (the `sha` parameter accepts - # a SHA): listing from main would include PRs merged to main - # after the tag but dated inside the window. --required-author="" - # includes bot-authored PRs (agents open many of our PRs). Write - # outside the checkout: GoReleaser refuses a dirty git tree. - export BRANCH="${END_SHA}" - # Gather as JSON, then render with our own script. The tool - # credits a commit to any PR cited as "(#N)" in its message, so - # PRs from earlier releases can appear; the renderer keeps only - # PRs actually merged in the range (first-parent commits between - # PREV and TAG) and groups notes by PR title type, mirroring the - # old GoReleaser changelog layout. - release-notes generate \ - --required-author="" \ - --dependencies=false \ - --format json \ - --output "${RUNNER_TEMP}/release-notes.json" \ - --org fullsend-ai --repo fullsend - # PRs merged in this release: merge commits say "Merge pull - # request #N"; squash-merge subjects end with "(#N)". - git log --first-parent --format='%s' "${PREV}..${TAG}" \ - | sed -nE 's/^Merge pull request #([0-9]+).*/\1/p; s/.*\(#([0-9]+)\)$/\1/p' \ - | sort -u > "${RUNNER_TEMP}/merged-prs.txt" - # Titles for the gathered PRs (one cheap API call each; only PRs - # with a release-note block reach this list). - : > "${RUNNER_TEMP}/pr-titles.tsv" - while read -r pr; do - gh pr view "${pr}" --json number,title \ - --jq '"\(.number)\t\(.title)"' >> "${RUNNER_TEMP}/pr-titles.tsv" - done < <(jq -r 'keys[]' "${RUNNER_TEMP}/release-notes.json") - bash scripts/render-release-notes.sh \ - "${RUNNER_TEMP}/release-notes.json" \ - "${RUNNER_TEMP}/merged-prs.txt" \ - "${RUNNER_TEMP}/pr-titles.tsv" \ - > "${RUNNER_TEMP}/release-notes-body.md" - # Prepend the header prepend-release-highlights.sh expects, so - # the release-highlights step keeps working with the - # gathered-notes body. - printf '## Changelog\n\n' | cat - "${RUNNER_TEMP}/release-notes-body.md" \ - > "${RUNNER_TEMP}/release-notes.md" + # The gather logic (pinned release-notes install, JSON gather, + # rendering) lives in the shared script so the workflow_dispatch + # dry-run job measures the exact same path. Output goes outside + # the checkout: GoReleaser refuses a dirty git tree. + bash scripts/gather-release-notes.sh "${PREV}" "${TAG}" "${RUNNER_TEMP}" # GoReleaser signs the release here. Installed CLIs only accept a # signature made by this workflow file, for the tag, on a @@ -193,6 +140,7 @@ jobs: fi validate-agents: + if: github.event_name == 'push' needs: resolve-agents # Permission contract of the called workflow. GitHub validates this at # parse time, before any job runs or `if:` is evaluated — a called @@ -222,6 +170,7 @@ jobs: EVAL_GH_TOKEN: ${{ secrets.EVAL_GH_TOKEN }} resolve-agents: + if: github.event_name == 'push' # Resolve agents main once at release start. Since agents#1010 the gate # itself reports the SHA it validated (validate-agents' agents_sha # output), and tag-agents prefers that; this job's resolution is the @@ -288,6 +237,7 @@ jobs: run: bash scripts/check-agents-gate-pin.sh recheck-tag: + if: github.event_name == 'push' # Second half of the tag-move guard. validate-agents clones fullsend by # tag name — the called workflow only accepts `main` or a `v*` ref and # uses `git clone --branch`, so it cannot be pinned to a SHA from this @@ -317,6 +267,7 @@ jobs: run: bash scripts/verify-release-tag.sh tag-agents: + if: github.event_name == 'push' # Sync the version tag to fullsend-ai/agents. Runs for all tags # including pre-releases — agents' own release.yml handles # pre-release semantics. Only runs after agents functional tests @@ -379,7 +330,8 @@ jobs: # otherwise a blocked release is silent on Slack. needs: [validate-agents, resolve-agents, recheck-tag] if: >- - always() + github.event_name == 'push' + && always() && (needs.validate-agents.result == 'failure' || needs.resolve-agents.result == 'failure' || needs.recheck-tag.result == 'failure') @@ -407,7 +359,8 @@ jobs: # passed, and their failure is reported by notify-release-blocked. needs: [release, tag-agents] if: >- - always() + github.event_name == 'push' + && always() && needs.release.result == 'success' && needs.tag-agents.result == 'failure' runs-on: ubuntu-24.04 @@ -426,3 +379,47 @@ jobs: PAYLOAD=$(jq -n --arg tag "${GITHUB_REF_NAME}" --arg url "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" \ '{text: ":warning: Agents tag sync failed for `\($tag)`. The fullsend release shipped but the agents tag was not created. <\($url)|View run>"}') curl -fsS -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "$SLACK_WEBHOOK" + + gather-dry-run: + # Measures the release-notes gather step with the workflow's own + # GITHUB_TOKEN (the smoke test in #9704 used a personal token, whose + # budget differs). Records the core rate limit before and after plus + # the runtime, so the release job's timeout-minutes can be set from + # data instead of guesswork. Nothing is built or published. + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-24.04 + # Generous on purpose: on a rate-limit error the release-notes tool + # waits for the reset window (up to an hour). The point of the dry + # run is to observe that behaviour, not to cut it off at the release + # job's 20 minutes. + timeout-minutes: 60 + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Record rate limit before + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh api rate_limit --jq '.resources.core | "core before \(.remaining)/\(.limit) (reset \(.reset))"' + + - name: Gather release notes (dry run) + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + START_TAG: ${{ inputs.start-tag }} + END_TAG: ${{ inputs.end-tag }} + run: | + set -euo pipefail + SECONDS=0 + bash scripts/gather-release-notes.sh "${START_TAG}" "${END_TAG}" "${RUNNER_TEMP}" + echo "gather runtime: ${SECONDS}s" + echo "gathered notes:" + cat "${RUNNER_TEMP}/release-notes.md" + + - name: Record rate limit after + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: gh api rate_limit --jq '.resources.core | "core after \(.remaining)/\(.limit) (reset \(.reset))"' diff --git a/scripts/check-release-note.sh b/scripts/check-release-note.sh index c9eb2109d7..acc114c648 100755 --- a/scripts/check-release-note.sh +++ b/scripts/check-release-note.sh @@ -86,6 +86,9 @@ fi # then `!` before the colon, e.g. "feat(harness)!:" or "fix!:". BREAKING_RE='^[[:alpha:]]+(\([^)]*\))?!:' +# The "no note" sentinels the gatherer excludes, mirroring its regex. +SENTINEL_PAT='none|n/a|na' + has_breaking_marker() { local text="$1" [[ -z "${text}" ]] && return 1 @@ -98,12 +101,12 @@ has_breaking_marker() { # are NOT excluded by the gatherer — it would publish the literal text — # so they are rejected below instead. is_none_block() { - [[ "${NOTE_TRIMMED,,}" =~ ^(none|n/a|na)$ ]] + [[ "${NOTE_TRIMMED,,}" =~ ^(${SENTINEL_PAT})$ ]] } # A quoted sentinel would be published literally by the gatherer. is_quoted_none_block() { - local re="^['\"](none|n/a|na)['\"]$" + local re="^['\"](${SENTINEL_PAT})['\"]$" [[ "${NOTE_TRIMMED,,}" =~ ${re} ]] } @@ -115,7 +118,9 @@ is_quoted_none_block() { matches_exclusion_filter() { local oneline oneline=$(tr '\n' ' ' <<<"${PR_BODY}") - grep -Eiq '```release-notes?[[:space:]]*(none|n/a|na)[[:space:]]*```' <<<"${oneline}" || + local fenced_re + fenced_re='```release-notes?[[:space:]]*('"${SENTINEL_PAT}"')[[:space:]]*```' + grep -Eiq "${fenced_re}" <<<"${oneline}" || grep -q '/release-note-none' <<<"${PR_BODY}" } diff --git a/scripts/gather-release-notes.sh b/scripts/gather-release-notes.sh new file mode 100644 index 0000000000..70e42be76b --- /dev/null +++ b/scripts/gather-release-notes.sh @@ -0,0 +1,91 @@ +#!/usr/bin/env bash +# gather-release-notes.sh — Gather release notes from release-note blocks +# in PR bodies for a tag range. +# +# Shared by the release workflow (.github/workflows/release.yml) and its +# workflow_dispatch dry-run job, which measures the GITHUB_TOKEN +# rate-limit cost and runtime before a final release relies on it. +# +# Usage: gather-release-notes.sh PREV_TAG TAG OUTDIR +# +# Writes OUTDIR/release-notes.md (with the "## Changelog" header the +# release-highlights step expects) and OUTDIR/release-notes-body.md. +# Requires gh (authenticated) for PR title lookups. + +set -euo pipefail + +if [[ $# -ne 3 ]]; then + echo "usage: $0 PREV_TAG TAG OUTDIR" >&2 + exit 2 +fi + +PREV="$1" +TAG="$2" +OUTDIR="$3" +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Install the pinned Kubernetes release-notes tool if absent. Update the +# URL and digest together (see scripts/renovate/ for the checksum-pinning +# convention). +if ! command -v release-notes >/dev/null 2>&1; then + RELEASE_NOTES_SHA256=16e0ada3e3602c229e97fa789ea97c7d128710d7fe1fee9f12c00f7eaa770d6a + curl -fsSLo "${OUTDIR}/release-notes" \ + https://github.com/kubernetes/release/releases/download/v0.17.1/release-notes-amd64-linux + echo "${RELEASE_NOTES_SHA256} ${OUTDIR}/release-notes" | sha256sum -c - + chmod +x "${OUTDIR}/release-notes" + sudo mv "${OUTDIR}/release-notes" /usr/local/bin/release-notes +fi + +echo "Gathering notes from ${PREV} to ${TAG}" +# The tool lists commits from START_SHA's commit date onward (inclusive). +# Use the first first-parent commit after PREV: picking the oldest-dated +# commit in the range would open the window before PREV (PR-branch +# commits can carry dates older than PREV) and re-list PRs from the +# previous release. +RANGE=$(git rev-list --first-parent --reverse "${PREV}..${TAG}") +if [[ -n "${RANGE}" ]]; then + START_SHA=$(head -n1 <<<"${RANGE}") +else + # PREV and TAG share a commit (a re-tag); fall back to PREV. + START_SHA=$(git rev-list -n1 "${PREV}") +fi +END_SHA=$(git rev-list -n1 "${TAG}") +# The tool reads its range and branch from these env vars. Use the tag's +# SHA as the listing ref (the `sha` parameter accepts a SHA): listing +# from main would include PRs merged to main after the tag but dated +# inside the window. --required-author="" includes bot-authored PRs +# (agents open many of our PRs). +export START_SHA END_SHA +export BRANCH="${END_SHA}" +# Gather as JSON, then render with our own script. The tool credits a +# commit to any PR cited as "(#N)" in its message, so PRs from earlier +# releases can appear; the renderer keeps only PRs actually merged in +# the range (first-parent commits between PREV and TAG) and groups notes +# by PR title type, mirroring the old GoReleaser changelog layout. +release-notes generate \ + --required-author="" \ + --dependencies=false \ + --format json \ + --output "${OUTDIR}/release-notes.json" \ + --org fullsend-ai --repo fullsend +# PRs merged in this release: merge commits say "Merge pull request #N"; +# squash-merge subjects end with "(#N)". +git log --first-parent --format='%s' "${PREV}..${TAG}" \ + | sed -nE 's/^Merge pull request #([0-9]+).*/\1/p; s/.*\(#([0-9]+)\)$/\1/p' \ + | sort -u > "${OUTDIR}/merged-prs.txt" +# Titles for the gathered PRs (one cheap API call each; only PRs with a +# release-note block reach this list). +: > "${OUTDIR}/pr-titles.tsv" +while read -r pr; do + gh pr view "${pr}" --json number,title \ + --jq '"\(.number)\t\(.title)"' >> "${OUTDIR}/pr-titles.tsv" +done < <(jq -r 'keys[]' "${OUTDIR}/release-notes.json") +bash "${SCRIPT_DIR}/render-release-notes.sh" \ + "${OUTDIR}/release-notes.json" \ + "${OUTDIR}/merged-prs.txt" \ + "${OUTDIR}/pr-titles.tsv" \ + > "${OUTDIR}/release-notes-body.md" +# Prepend the header prepend-release-highlights.sh expects, so the +# release-highlights step keeps working with the gathered-notes body. +printf '## Changelog\n\n' | cat - "${OUTDIR}/release-notes-body.md" \ + > "${OUTDIR}/release-notes.md" diff --git a/skills/cutting-releases/SKILL.md b/skills/cutting-releases/SKILL.md index 05fd1767c5..31a670de2d 100644 --- a/skills/cutting-releases/SKILL.md +++ b/skills/cutting-releases/SKILL.md @@ -299,6 +299,12 @@ installs the binary as `fullsend-` so multiple versions can coexist. working), followed by **Urgent Upgrade Notes** (PRs labeled `release-note-action-required`, applied automatically when a PR's block starts with `action required`) and **Changes by Kind**. +- **Gather dry-run:** the Release workflow has a `workflow_dispatch` + trigger that runs only the release-notes gather step over a tag range + with the workflow's own `GITHUB_TOKEN`, recording the core rate limit + before and after plus the runtime. Run it over a recent final range + before relying on the gather step for a final release (its API budget + differs from a personal token's). - **The `v0` tag** is a moving tag consumed by downstream orgs for reusable workflows. It is automatically moved by the release workflow after GoReleaser completes (skipped for pre-release tags). From f5e359a4c947239fabcdaf75d6ca68330e832750 Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 25 Nov 2026 12:05:12 +0100 Subject: [PATCH 6/9] fix(ci): pass GITHUB_TOKEN to the gather dry-run The release-notes tool only reads GITHUB_TOKEN; the dry-run job set GH_TOKEN, so the gather failed. gh accepts GITHUB_TOKEN as well. Assisted-By: Claude Sonnet 4.5 (pi) Signed-off-by: Hector Martinez --- .github/workflows/release.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 34da2c1fdf..54f23e4245 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -403,12 +403,14 @@ jobs: - name: Record rate limit before env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # GITHUB_TOKEN (not GH_TOKEN): the release-notes tool only reads + # GITHUB_TOKEN; gh accepts it too. + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh api rate_limit --jq '.resources.core | "core before \(.remaining)/\(.limit) (reset \(.reset))"' - name: Gather release notes (dry run) env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} START_TAG: ${{ inputs.start-tag }} END_TAG: ${{ inputs.end-tag }} run: | @@ -421,5 +423,5 @@ jobs: - name: Record rate limit after env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh api rate_limit --jq '.resources.core | "core after \(.remaining)/\(.limit) (reset \(.reset))"' From a70b6ee8f7361c73790517d2420b0b46139ce0e9 Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Wed, 25 Nov 2026 16:17:16 +0100 Subject: [PATCH 7/9] ci(release): address release-notes review feedback - Split release-note-check into a read-only validation job and a narrowly scoped label-sync job (only the latter holds pull-requests: write). - Wrap the gather-dry-run notes output in a stop-commands token so contributor-controlled markdown cannot emit workflow commands. - Fail the gather when a merged PR's body was edited after merge (lastEditedAt vs mergedAt via GraphQL). - List merged PRs without a release note under 'PRs Without Release Notes' instead of dropping them silently; warn on missing notes and on zero notes from a non-empty range; soften the 'CI enforces' wording in AGENTS.md and CONTRIBUTING.md. - Bump the pinned release-notes tool to v0.23.0, add a Renovate custom manager plus update-release-notes-checksum.sh so version and digest move together, and move the gather into its own read-only job that hands the markdown to the signing job as an artifact. - Make the label-sync failure message neutral instead of blaming a fork. - Add gather-release-notes-test.sh for the range math and merged-PR extraction, registered in the Makefile script-test target. Assisted-By: glm-5-3(pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 31 ++- .github/workflows/release.yml | 107 ++++++--- AGENTS.md | 5 +- CONTRIBUTING.md | 5 +- Makefile | 1 + renovate.json | 21 ++ scripts/gather-release-notes-test.sh | 128 +++++++++++ scripts/gather-release-notes.sh | 213 ++++++++++++------ scripts/render-release-notes-test.sh | 51 +++++ scripts/render-release-notes.sh | 31 +++ .../renovate/update-release-notes-checksum.sh | 34 +++ skills/cutting-releases/SKILL.md | 15 +- 12 files changed, 516 insertions(+), 126 deletions(-) create mode 100644 scripts/gather-release-notes-test.sh create mode 100644 scripts/renovate/update-release-notes-checksum.sh diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index ef6597923c..4e53e20eaf 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -26,13 +26,12 @@ jobs: if: github.event_name == 'pull_request' runs-on: ubuntu-24.04 timeout-minutes: 5 - # Note: permissions are granted at job scope, so every step in this - # job — including checkout and validation — runs with a token that can - # write to PRs on same-repo runs (fork tokens are downgraded by - # GitHub). Only the label-sync step below actually writes. permissions: contents: read - pull-requests: write + outputs: + # Consumed by the sync-action-required-label job below; empty when + # the note is not action-required (or the bootstrap skip ran). + action-required: ${{ steps.check.outputs.action-required }} steps: # Check out the PR's base ref, not the PR head: the validator must # come from a trusted revision so a PR cannot neuter its own check @@ -74,15 +73,25 @@ jobs: # The script appends action-required=1 to GITHUB_OUTPUT when the # accepted note starts with "action required". - # The release-notes gatherer lists a note under "Urgent Upgrade - # Notes" only when the PR carries this label (it also strips the - # "action required:" prefix from the note text), so keep the label in - # sync with the check result. + # The release-notes gatherer lists a note under "Urgent Upgrade + # Notes" only when the PR carries this label (it also strips the + # "action required:" prefix from the note text), so keep the label in + # sync with the check result. This is the only job with + # pull-requests: write; the validation job above stays read-only. + sync-action-required-label: + if: github.event_name == 'pull_request' + needs: release-note-check + runs-on: ubuntu-24.04 + timeout-minutes: 5 + permissions: + contents: read + pull-requests: write + steps: - name: Sync action-required label env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - ACTION_REQUIRED: ${{ steps.check.outputs.action-required }} + ACTION_REQUIRED: ${{ needs.release-note-check.outputs.action-required }} run: | set -euo pipefail # Fork PRs run with a read-only token and cannot create or add @@ -105,7 +114,7 @@ jobs: --description "Release-note block starts with 'action required'" --force \ || echo "::warning::could not create label (it may already exist)" if ! gh pr edit "${PR_NUMBER}" --add-label release-note-action-required; then - echo "::error::This PR needs the release-note-action-required label (its release-note block starts with 'action required'), but the label could not be added (fork PR with a read-only token). A maintainer must add it before merge." + echo "::error::This PR needs the release-note-action-required label (its release-note block starts with 'action required'), but the label could not be added — the token cannot write (a fork PR) or the API call failed. A maintainer must add it before merge." exit 1 fi else diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 54f23e4245..3cabf6ec14 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,14 +23,11 @@ permissions: jobs: release: if: github.event_name == 'push' - needs: [validate-agents, resolve-agents, recheck-tag] + needs: [validate-agents, resolve-agents, recheck-tag, gather-release-notes] runs-on: ubuntu-24.04 - # pull-requests: read is needed by release-notes generate, which reads - # merged PR bodies to gather the release-note blocks. permissions: contents: write id-token: write - pull-requests: read # Historically ~2 minutes. Bounded so a hung publish cannot hold the # tag-agents sync (and the default 6h limit) open. timeout-minutes: 20 @@ -70,38 +67,14 @@ jobs: echo "current=${TAG} previous=${PREV:-}" # Release notes come from `release-note` blocks in PR bodies (see - # COMMITS.md, "Release notes"), gathered with the Kubernetes - # release-notes tool — the same approach kubearchive uses. The tool - # reads the blocks from the merged PRs in the tag range, skips NONE - # entries, and renders markdown. GoReleaser then publishes that - # markdown instead of its commit-subject changelog. - - name: Generate release notes from PR bodies - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - TAG: ${{ github.ref_name }} - run: | - set -euo pipefail - # Previous tag: for a final release, the last final release, so - # the notes span the whole release. For an rc, the tag - # immediately before this one (usually the previous rc), so an - # rc only lists what changed since that tag — matching - # GoReleaser's default previous-tag resolution for rc tags. - TAGS=$(git tag --merged "${TAG}^{commit}" --sort=-v:refname --list 'v[0-9]*.[0-9]*.[0-9]*') - case "${TAG}" in - *-*) PREV=$(printf '%s\n' "$TAGS" | grep -vxF -e "$TAG" | head -n1 || true) ;; - *) PREV=$(printf '%s\n' "$TAGS" | grep -v -e '-' | grep -vxF -e "$TAG" | head -n1 || true) ;; - esac - if [[ -z "${PREV}" ]]; then - # Static message: interpolating TAG here would need workflow-command - # escaping (%0A/%0D) to stay injection-safe. - echo "::error::Could not find a previous release tag before the current tag" - exit 1 - fi - # The gather logic (pinned release-notes install, JSON gather, - # rendering) lives in the shared script so the workflow_dispatch - # dry-run job measures the exact same path. Output goes outside - # the checkout: GoReleaser refuses a dirty git tree. - bash scripts/gather-release-notes.sh "${PREV}" "${TAG}" "${RUNNER_TEMP}" + # COMMITS.md, "Release notes"), gathered by the + # gather-release-notes job below and passed here as an artifact, so + # the untrusted-PR-body parsing never runs inside this signing job. + - name: Download release notes + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-notes + path: ${{ runner.temp }} # GoReleaser signs the release here. Installed CLIs only accept a # signature made by this workflow file, for the tag, on a @@ -380,6 +353,60 @@ jobs: '{text: ":warning: Agents tag sync failed for `\($tag)`. The fullsend release shipped but the agents tag was not created. <\($url)|View run>"}') curl -fsS -X POST -H "Content-Type: application/json" -d "$PAYLOAD" "$SLACK_WEBHOOK" + # Gathers the release notes from PR bodies in a read-only job, so the + # pinned release-notes binary (which parses contributor-controlled PR + # bodies) never runs inside the signing job. The rendered markdown is + # passed to the release job as an artifact. + gather-release-notes: + if: github.event_name == 'push' + runs-on: ubuntu-24.04 + # Generous on purpose: on a rate-limit error the release-notes tool + # waits for the reset window (up to an hour), matching the dry-run + # job's budget. + timeout-minutes: 60 + permissions: + contents: read + pull-requests: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + + - name: Generate release notes from PR bodies + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAG: ${{ github.ref_name }} + run: | + set -euo pipefail + # Previous tag: for a final release, the last final release, so + # the notes span the whole release. For an rc, the tag + # immediately before this one (usually the previous rc), so an + # rc only lists what changed since that tag — matching + # GoReleaser's default previous-tag resolution for rc tags. + TAGS=$(git tag --merged "${TAG}^{commit}" --sort=-v:refname --list 'v[0-9]*.[0-9]*.[0-9]*') + case "${TAG}" in + *-*) PREV=$(printf '%s\n' "$TAGS" | grep -vxF -e "$TAG" | head -n1 || true) ;; + *) PREV=$(printf '%s\n' "$TAGS" | grep -v -e '-' | grep -vxF -e "$TAG" | head -n1 || true) ;; + esac + if [[ -z "${PREV}" ]]; then + # Static message: interpolating TAG here would need workflow-command + # escaping (%0A/%0D) to stay injection-safe. + echo "::error::Could not find a previous release tag before the current tag" + exit 1 + fi + # The gather logic (pinned release-notes install, JSON gather, + # rendering) lives in the shared script so the workflow_dispatch + # dry-run job measures the exact same path. Output goes outside + # the checkout: GoReleaser refuses a dirty git tree. + bash scripts/gather-release-notes.sh "${PREV}" "${TAG}" "${RUNNER_TEMP}" + + - name: Upload release notes + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-notes + path: ${{ runner.temp }}/release-notes.md + if-no-files-found: error + gather-dry-run: # Measures the release-notes gather step with the workflow's own # GITHUB_TOKEN (the smoke test in #9704 used a personal token, whose @@ -419,7 +446,15 @@ jobs: bash scripts/gather-release-notes.sh "${START_TAG}" "${END_TAG}" "${RUNNER_TEMP}" echo "gather runtime: ${SECONDS}s" echo "gathered notes:" + # The notes derive from contributor-controlled PR bodies. Wrap + # the output in a stop-commands token so nothing in it can be + # interpreted as a workflow command (::error::, ::add-mask::, + # ::stop-commands::). The token is runner-generated and not + # present in the output. + STOP_TOKEN="stop-commands-$(head -c 16 /dev/urandom | od -An -tx1 | tr -d ' \n')" + echo "::stop-commands::${STOP_TOKEN}" cat "${RUNNER_TEMP}/release-notes.md" + echo "::${STOP_TOKEN}::" - name: Record rate limit after env: diff --git a/AGENTS.md b/AGENTS.md index 00e37c49d5..cf3de2801c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -41,8 +41,9 @@ full documentation site. binary to avoid stale state. See [Go Code § Running the fullsend CLI](docs/contributing/go-code.md#running-the-fullsend-cli). - Follow [COMMITS.md](COMMITS.md) when writing or reviewing commit messages - and PR titles. Every PR must carry a `release-note` block in its body (CI - enforces it); release notes come from those blocks, not commit prefixes. + and PR titles. Every PR must carry a `release-note` block in its body (the + Release Note Check workflow validates it); release notes come from those + blocks, not commit prefixes. Breaking changes require the `!` marker in both commit subjects and PR titles, and an `action required` release-note block (CI labels such PRs `release-note-action-required` so the note lands under Urgent Upgrade diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 713dad1d53..f7838c473a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -44,8 +44,9 @@ contribution. same checks in a container that matches the CI runner, so local results predict CI (see [`hack/ci-local`](hack/ci-local/README.md)). - Every PR must carry a `release-note` block in its body — the PR template - provides one with a `NONE` default. CI rejects a PR whose block is missing - or empty. See [COMMITS.md](COMMITS.md#release-notes) for how to write it. + provides one with a `NONE` default. The Release Note Check workflow + rejects a PR whose block is missing or empty. See + [COMMITS.md](COMMITS.md#release-notes) for how to write it. - **If your PR introduces a breaking change**, the PR title and every breaking commit's subject must carry the `!` suffix (e.g., `feat(harness)!: require role field`), and the PR's `release-note` block must start with diff --git a/Makefile b/Makefile index 001093c44f..d79ee24e16 100644 --- a/Makefile +++ b/Makefile @@ -189,6 +189,7 @@ endef script-test: $(call run-timed,bash scripts/check-release-note-test.sh) $(call run-timed,bash scripts/render-release-notes-test.sh) + $(call run-timed,bash scripts/gather-release-notes-test.sh) $(call run-timed,bash scripts/check-live-test-relevance-test.sh) $(call run-timed,bash scripts/check-e2e-authorization-test.sh) $(call run-timed,bash scripts/vouch-sweep-test.sh) diff --git a/renovate.json b/renovate.json index 06d991e0ea..736a0e509f 100644 --- a/renovate.json +++ b/renovate.json @@ -142,6 +142,16 @@ "executionMode": "branch" } }, + { + "description": "After a kubernetes/release bump, refresh RELEASE_NOTES_SHA256 in gather-release-notes.sh, checked against the digest GitHub records for the asset. Human-reviewed: the binary parses contributor-controlled PR bodies inside the release path.", + "matchPackageNames": ["kubernetes/release"], + "automerge": false, + "postUpgradeTasks": { + "commands": ["bash scripts/renovate/update-release-notes-checksum.sh"], + "fileFilters": ["scripts/gather-release-notes.sh"], + "executionMode": "branch" + } + }, { "description": "After an fd bump, refresh FD_SHA256_{AMD64,ARM64} in the sandbox Containerfile. fd ships no checksum file, so the download is checked against the digest GitHub records for each release asset (#9121)", "matchPackageNames": ["sharkdp/fd"], @@ -517,6 +527,17 @@ "depNameTemplate": "sigstore/gitsign", "datasourceTemplate": "github-releases", "extractVersionTemplate": "^v(?\\d+\\.\\d+\\.\\d+)$" + }, + { + "customType": "regex", + "description": "Track the pinned Kubernetes release-notes tool in gather-release-notes.sh. RELEASE_NOTES_SHA256 is refreshed in the same PR by postUpgradeTasks (scripts/renovate/update-release-notes-checksum.sh), checked against the digest GitHub records for the asset.", + "managerFilePatterns": ["/^scripts/gather-release-notes\\.sh$/"], + "matchStrings": [ + "releases/download/v(?[^/]+)/release-notes-amd64-linux" + ], + "depNameTemplate": "kubernetes/release", + "datasourceTemplate": "github-releases", + "extractVersionTemplate": "^v(?.*)$" } ] } diff --git a/scripts/gather-release-notes-test.sh b/scripts/gather-release-notes-test.sh new file mode 100644 index 0000000000..6aacd2d106 --- /dev/null +++ b/scripts/gather-release-notes-test.sh @@ -0,0 +1,128 @@ +#!/usr/bin/env bash +# gather-release-notes-test.sh — Tests for the pure functions of +# gather-release-notes.sh (range math and merged-PR extraction). +# +# The full script needs the release-notes binary and an authenticated +# gh, so only the offline parts are exercised here: compute_start_sha +# (first-parent selection, the old-date trap, the re-tag fallback) and +# extract_merged_prs (merge commits and squash subjects). +# +# Run from the repo root: +# bash scripts/gather-release-notes-test.sh + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# shellcheck source=scripts/gather-release-notes.sh +source "${SCRIPT_DIR}/gather-release-notes.sh" + +TMP=$(mktemp -d) +trap 'rm -rf "${TMP}"' EXIT + +FAILURES=0 + +ok() { + echo "ok — $1" +} + +fail() { + echo "FAIL — $1" + echo "--- expected ---" + printf '%s\n' "$2" + echo "--- actual ---" + printf '%s\n' "$3" + FAILURES=$((FAILURES + 1)) +} + +assert_equals() { + local desc=$1 expected=$2 actual=$3 + if [[ "${actual}" == "${expected}" ]]; then + ok "${desc}" + else + fail "${desc}" "${expected}" "${actual}" + fi +} + +# Build a repo shaped like a real release range: +# +# A --- B(merge #1) --- C(squash #2) --- D(merge #3) <- TAG +# \ +# E (old-dated PR-branch commit for #1) +# +# E carries a commit date older than PREV, so an oldest-date START_SHA +# selection would open the window before PREV and re-list PR #1. +build_repo() { + git -C "${TMP}" init -q -b main + git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "A" + # PREV points at A. + git -C "${TMP}" tag v0.1.0 + + # PR #1: a branch with an old-dated commit, merged with a merge commit. + git -C "${TMP}" checkout -q -b pr1 + # 2000-01-01: far older than PREV. + GIT_COMMITTER_DATE="2000-01-01T00:00:00Z" GIT_AUTHOR_DATE="2000-01-01T00:00:00Z" \ + git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "E" + git -C "${TMP}" checkout -q main + git -C "${TMP}" -c user.email=t@t -c user.name=t merge -q --no-ff -m "Merge pull request #1 from x/pr1" pr1 + + # PR #2: squash merge (subject ends with "(#2)"). + git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "feat: thing (#2)" + + # PR #3: another merge commit. + git -C "${TMP}" checkout -q -b pr3 + git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "F" + git -C "${TMP}" checkout -q main + git -C "${TMP}" -c user.email=t@t -c user.name=t merge -q --no-ff -m "Merge pull request #3 from x/pr3" pr3 + + git -C "${TMP}" tag v0.2.0 +} + +build_repo + +# The functions run git in the current directory; run them inside the +# temp repo. +cd "${TMP}" + +# --- compute_start_sha ---------------------------------------------------- + +# START_SHA must be the first first-parent commit after PREV (the #1 +# merge), not the old-dated PR-branch commit E. +EXPECTED_START=$(git -C "${TMP}" rev-list --first-parent --reverse v0.1.0..v0.2.0 | head -n1) +assert_equals "compute_start_sha picks the first first-parent commit after PREV" \ + "${EXPECTED_START}" "$(compute_start_sha v0.1.0 v0.2.0)" + +# START_SHA must not be E even though E is the oldest-dated commit in +# the range. +OLD_DATED=$(git -C "${TMP}" rev-list v0.1.0..v0.2.0 | while read -r c; do + printf '%s %s\n' "$(git -C "${TMP}" show -s --format=%ct "${c}")" "${c}" +done | sort -n | head -n1 | cut -d' ' -f2) +if [[ "$(compute_start_sha v0.1.0 v0.2.0)" != "${OLD_DATED}" ]]; then + ok "compute_start_sha ignores the old-dated PR-branch commit" +else + fail "compute_start_sha ignores the old-dated PR-branch commit" \ + "not ${OLD_DATED}" "${OLD_DATED}" +fi + +# Re-tag: PREV and TAG on the same commit falls back to PREV itself. +git -C "${TMP}" tag v0.2.0-same "$(git -C "${TMP}" rev-parse v0.1.0)" +assert_equals "compute_start_sha falls back to PREV on a re-tag" \ + "$(git -C "${TMP}" rev-parse v0.1.0)" "$(compute_start_sha v0.1.0 v0.2.0-same)" + +# --- extract_merged_prs --------------------------------------------------- + +assert_equals "extract_merged_prs finds merge commits and squash subjects" \ + "1 +2 +3" "$(extract_merged_prs v0.1.0 v0.2.0)" + +# A range with no merges yields nothing. +git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "chore: no PR" +git -C "${TMP}" tag v0.3.0 +assert_equals "extract_merged_prs returns nothing for a PR-less range" \ + "" "$(extract_merged_prs v0.2.0 v0.3.0)" + +if [[ "${FAILURES}" -gt 0 ]]; then + echo "${FAILURES} failure(s)" >&2 + exit 1 +fi +echo "all tests passed" diff --git a/scripts/gather-release-notes.sh b/scripts/gather-release-notes.sh index 70e42be76b..aa2c1865ca 100644 --- a/scripts/gather-release-notes.sh +++ b/scripts/gather-release-notes.sh @@ -10,82 +10,155 @@ # # Writes OUTDIR/release-notes.md (with the "## Changelog" header the # release-highlights step expects) and OUTDIR/release-notes-body.md. -# Requires gh (authenticated) for PR title lookups. +# Requires gh (authenticated) for PR title and edit-timestamp lookups. +# +# The range math and merged-PR extraction live in functions below so +# gather-release-notes-test.sh can exercise them offline (the full run +# needs the release-notes binary and an authenticated gh). set -euo pipefail -if [[ $# -ne 3 ]]; then - echo "usage: $0 PREV_TAG TAG OUTDIR" >&2 - exit 2 -fi - -PREV="$1" -TAG="$2" -OUTDIR="$3" -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +# Install the pinned Kubernetes release-notes tool if absent (in main, +# after the args are parsed). Update the URL and digest together: Renovate +# bumps the version (custom manager in renovate.json) and +# scripts/renovate/update-release-notes-checksum.sh refreshes the digest in +# the same PR. v0.17.1 was replaced by v0.23.0 (current at the time) +# because the old pin was ~2.4 years stale and nothing could bump it. +install_release_notes() { + local outdir=$1 + local RELEASE_NOTES_SHA256=086ef82292e97a1dcc3b4e096ea40627a78b0ef3a2564f2faf324acc11f75724 + curl -fsSLo "${outdir}/release-notes" \ + https://github.com/kubernetes/release/releases/download/v0.23.0/release-notes-amd64-linux + echo "${RELEASE_NOTES_SHA256} ${outdir}/release-notes" | sha256sum -c - + chmod +x "${outdir}/release-notes" + sudo mv "${outdir}/release-notes" /usr/local/bin/release-notes +} -# Install the pinned Kubernetes release-notes tool if absent. Update the -# URL and digest together (see scripts/renovate/ for the checksum-pinning -# convention). -if ! command -v release-notes >/dev/null 2>&1; then - RELEASE_NOTES_SHA256=16e0ada3e3602c229e97fa789ea97c7d128710d7fe1fee9f12c00f7eaa770d6a - curl -fsSLo "${OUTDIR}/release-notes" \ - https://github.com/kubernetes/release/releases/download/v0.17.1/release-notes-amd64-linux - echo "${RELEASE_NOTES_SHA256} ${OUTDIR}/release-notes" | sha256sum -c - - chmod +x "${OUTDIR}/release-notes" - sudo mv "${OUTDIR}/release-notes" /usr/local/bin/release-notes -fi - -echo "Gathering notes from ${PREV} to ${TAG}" +# compute_start_sha PREV TAG — print the first first-parent commit after +# PREV on the path to TAG. +# # The tool lists commits from START_SHA's commit date onward (inclusive). # Use the first first-parent commit after PREV: picking the oldest-dated # commit in the range would open the window before PREV (PR-branch # commits can carry dates older than PREV) and re-list PRs from the -# previous release. -RANGE=$(git rev-list --first-parent --reverse "${PREV}..${TAG}") -if [[ -n "${RANGE}" ]]; then - START_SHA=$(head -n1 <<<"${RANGE}") -else - # PREV and TAG share a commit (a re-tag); fall back to PREV. - START_SHA=$(git rev-list -n1 "${PREV}") +# previous release. When PREV and TAG share a commit (a re-tag), fall +# back to PREV itself. +compute_start_sha() { + local prev=$1 tag=$2 range + range=$(git rev-list --first-parent --reverse "${prev}..${tag}") + if [[ -n "${range}" ]]; then + head -n1 <<<"${range}" + else + git rev-list -n1 "${prev}" + fi +} + +# extract_merged_prs PREV TAG — print the PR numbers merged in the range, +# one per line, sorted and unique. Merge commits say "Merge pull request +# #N"; squash-merge subjects end with "(#N)". +extract_merged_prs() { + local prev=$1 tag=$2 + git log --first-parent --format='%s' "${prev}..${tag}" \ + | sed -nE 's/^Merge pull request #([0-9]+).*/\1/p; s/.*\(#([0-9]+)\)$/\1/p' \ + | sort -u +} + +# fetch_pr_meta PR — print a JSON object with the PR's title, lastEditedAt +# and mergedAt (one GraphQL call). lastEditedAt is null when the body was +# never edited. +fetch_pr_meta() { + local pr=$1 + gh api graphql \ + -f query='query($number: Int!) { + repository(owner: "fullsend-ai", name: "fullsend") { + pullRequest(number: $number) { + title + lastEditedAt + mergedAt + } + } + }' \ + -F number="${pr}" \ + --jq '.data.repository.pullRequest' +} + +main() { + if [[ $# -ne 3 ]]; then + echo "usage: $0 PREV_TAG TAG OUTDIR" >&2 + exit 2 + fi + + local PREV=$1 TAG=$2 OUTDIR=$3 + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + + if ! command -v release-notes >/dev/null 2>&1; then + install_release_notes "${OUTDIR}" + fi + + echo "Gathering notes from ${PREV} to ${TAG}" + local START_SHA END_SHA + START_SHA=$(compute_start_sha "${PREV}" "${TAG}") + END_SHA=$(git rev-list -n1 "${TAG}") + # The tool reads its range and branch from these env vars. Use the tag's + # SHA as the listing ref (the `sha` parameter accepts a SHA): listing + # from main would include PRs merged to main after the tag but dated + # inside the window. --required-author="" includes bot-authored PRs + # (agents open many of our PRs). + export START_SHA END_SHA + export BRANCH="${END_SHA}" + # Gather as JSON, then render with our own script. The tool credits a + # commit to any PR cited as "(#N)" in its message, so PRs from earlier + # releases can appear; the renderer keeps only PRs actually merged in + # the range (first-parent commits between PREV and TAG) and groups notes + # by PR title type, mirroring the old GoReleaser changelog layout. + release-notes generate \ + --required-author="" \ + --dependencies=false \ + --format json \ + --output "${OUTDIR}/release-notes.json" \ + --org fullsend-ai --repo fullsend + # PRs merged in this release. + extract_merged_prs "${PREV}" "${TAG}" > "${OUTDIR}/merged-prs.txt" + # Titles and edit timestamps for every merged PR (one GraphQL call + # each). Titles feed the renderer's section grouping and its + # missing-note fallback; the timestamps feed the post-merge edit check + # below. + : > "${OUTDIR}/pr-titles.tsv" + local -a edited_after_merge=() + local pr meta title + while read -r pr; do + meta=$(fetch_pr_meta "${pr}") + title=$(jq -r '.title // ""' <<<"${meta}") + printf '%s\t%s\n' "${pr}" "${title}" >> "${OUTDIR}/pr-titles.tsv" + # The release-note check validates the body only before merge. After + # merge the author (including a fork contributor) can still edit the + # body, replacing a reviewed note with arbitrary markdown. Refuse to + # publish a note whose body was edited after the merge; a maintainer + # must review the edit (revert it or re-approve it) before releasing. + if jq -e ' + .lastEditedAt != null and .mergedAt != null + and .lastEditedAt > .mergedAt + ' >/dev/null <<<"${meta}"; then + edited_after_merge+=("${pr}") + fi + done < "${OUTDIR}/merged-prs.txt" + if [[ ${#edited_after_merge[@]} -gt 0 ]]; then + # PR numbers are numeric, so interpolating them needs no + # workflow-command escaping. + echo "::error::PRs whose body was edited after merge (the published note would differ from the reviewed one): ${edited_after_merge[*]}. A maintainer must review the edits before releasing." + exit 1 + fi + bash "${SCRIPT_DIR}/render-release-notes.sh" \ + "${OUTDIR}/release-notes.json" \ + "${OUTDIR}/merged-prs.txt" \ + "${OUTDIR}/pr-titles.tsv" \ + > "${OUTDIR}/release-notes-body.md" + # Prepend the header prepend-release-highlights.sh expects, so the + # release-highlights step keeps working with the gathered-notes body. + printf '## Changelog\n\n' | cat - "${OUTDIR}/release-notes-body.md" \ + > "${OUTDIR}/release-notes.md" +} + +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + main "$@" fi -END_SHA=$(git rev-list -n1 "${TAG}") -# The tool reads its range and branch from these env vars. Use the tag's -# SHA as the listing ref (the `sha` parameter accepts a SHA): listing -# from main would include PRs merged to main after the tag but dated -# inside the window. --required-author="" includes bot-authored PRs -# (agents open many of our PRs). -export START_SHA END_SHA -export BRANCH="${END_SHA}" -# Gather as JSON, then render with our own script. The tool credits a -# commit to any PR cited as "(#N)" in its message, so PRs from earlier -# releases can appear; the renderer keeps only PRs actually merged in -# the range (first-parent commits between PREV and TAG) and groups notes -# by PR title type, mirroring the old GoReleaser changelog layout. -release-notes generate \ - --required-author="" \ - --dependencies=false \ - --format json \ - --output "${OUTDIR}/release-notes.json" \ - --org fullsend-ai --repo fullsend -# PRs merged in this release: merge commits say "Merge pull request #N"; -# squash-merge subjects end with "(#N)". -git log --first-parent --format='%s' "${PREV}..${TAG}" \ - | sed -nE 's/^Merge pull request #([0-9]+).*/\1/p; s/.*\(#([0-9]+)\)$/\1/p' \ - | sort -u > "${OUTDIR}/merged-prs.txt" -# Titles for the gathered PRs (one cheap API call each; only PRs with a -# release-note block reach this list). -: > "${OUTDIR}/pr-titles.tsv" -while read -r pr; do - gh pr view "${pr}" --json number,title \ - --jq '"\(.number)\t\(.title)"' >> "${OUTDIR}/pr-titles.tsv" -done < <(jq -r 'keys[]' "${OUTDIR}/release-notes.json") -bash "${SCRIPT_DIR}/render-release-notes.sh" \ - "${OUTDIR}/release-notes.json" \ - "${OUTDIR}/merged-prs.txt" \ - "${OUTDIR}/pr-titles.tsv" \ - > "${OUTDIR}/release-notes-body.md" -# Prepend the header prepend-release-highlights.sh expects, so the -# release-highlights step keeps working with the gathered-notes body. -printf '## Changelog\n\n' | cat - "${OUTDIR}/release-notes-body.md" \ - > "${OUTDIR}/release-notes.md" diff --git a/scripts/render-release-notes-test.sh b/scripts/render-release-notes-test.sh index 281e76f48c..6d4d84550f 100755 --- a/scripts/render-release-notes-test.sh +++ b/scripts/render-release-notes-test.sh @@ -189,6 +189,57 @@ EOF check "empty notes render an empty body" '' +# --- PRs without a release note ------------------------------------------- + +# A merged PR absent from the notes JSON (no release-note block) must be +# listed under "PRs Without Release Notes" instead of vanishing, and a +# warning must go to stderr. +printf '601\tfix: has note\n602\tchore: no block\n' > "${TMP}/titles.tsv" +cat >"${TMP}/notes.json" <<'EOF' +{ + "601": {"pr_number": 601, "text": "Has a note.", + "pr_url": "https://example.com/pull/601", "author": "alice", + "author_url": "https://example.com/alice"} +} +EOF +printf '601\n602\n' > "${TMP}/merged.txt" + +actual=$("${SCRIPT}" "${TMP}/notes.json" "${TMP}/merged.txt" "${TMP}/titles.tsv" 2>"${TMP}/stderr") +expected='### Bug Fixes + +- Has a note. ([#601](https://example.com/pull/601), [@alice](https://example.com/alice)) + +### PRs Without Release Notes + +- #602 chore: no block' +if [[ "${actual}" == "${expected}" ]]; then + echo "ok — merged PR without a note is listed, not dropped" +else + fail "merged PR without a note is listed, not dropped" "${expected}" "${actual}" +fi +if grep -q "PRs merged in the range have no release note" "${TMP}/stderr"; then + echo "ok — missing-note warning goes to stderr" +else + echo "FAIL — missing-note warning goes to stderr" + cat "${TMP}/stderr" + FAILURES=$((FAILURES + 1)) +fi + +# A non-empty range that gathered zero notes must warn. +printf '701\tfeat: nothing\n' > "${TMP}/titles.tsv" +printf '{}' > "${TMP}/notes.json" +printf '701\n' > "${TMP}/merged.txt" + +"${SCRIPT}" "${TMP}/notes.json" "${TMP}/merged.txt" "${TMP}/titles.tsv" \ + >"${TMP}/stdout" 2>"${TMP}/stderr" +if grep -q "Zero release notes gathered" "${TMP}/stderr"; then + echo "ok — zero notes from a non-empty range warns" +else + echo "FAIL — zero notes from a non-empty range warns" + cat "${TMP}/stderr" + FAILURES=$((FAILURES + 1)) +fi + # --- Missing files -------------------------------------------------------- if "${SCRIPT}" "${TMP}/missing.json" "${TMP}/merged.txt" "${TMP}/titles.tsv" 2>/dev/null; then diff --git a/scripts/render-release-notes.sh b/scripts/render-release-notes.sh index 38b2841c3d..ca085b0ddd 100755 --- a/scripts/render-release-notes.sh +++ b/scripts/render-release-notes.sh @@ -47,6 +47,12 @@ TITLES=$(jq -Rn ' | .[$parts[0]] = ($parts[1] // "") )' "${TITLES_TSV}") +# Merged PRs that the tool returned no note for (no release-note block +# in the body). They are listed in the output under "PRs Without Release +# Notes" so they do not vanish from the release silently. +MISSING=$(jq -Rn --argjson allowed "${ALLOWED}" --slurpfile notes "${NOTES_JSON}" ' + $allowed - ($notes[0] | keys | map(tonumber))') + # One JSON object per line for each published note: number, title, # text, PR URL, author, author URL, action-required flag. Notes for PRs # outside the merged set, notes marked do-not-publish, and empty notes @@ -63,6 +69,18 @@ ROWS=$(jq -c --argjson allowed "${ALLOWED}" --argjson titles "${TITLES}" ' action_required: (.action_required == true)} ] | sort_by(.number) | .[]' "${NOTES_JSON}") +# Warn (to stderr, so it lands in the log, not the notes) when PRs +# merged in the range produced no note, or when a non-empty range +# gathered zero notes at all. Release Note Check is not a required +# status check, so this is the only signal that a change is about to +# drop out of the release. +if [[ -n "${MISSING}" ]] && [[ "${MISSING}" != "[]" ]]; then + echo "::warning::$(jq length <<<"${MISSING}") PRs merged in the range have no release note and will only be listed under 'PRs Without Release Notes'." >&2 +fi +if [[ -z "${ROWS}" ]] && [[ -n "${ALLOWED}" ]] && [[ "${ALLOWED}" != "[]" ]]; then + echo "::warning::Zero release notes gathered from a range containing $(jq length <<<"${ALLOWED}") merged PRs." >&2 +fi + # Section for a note, in priority order. Action-required notes always go # under Urgent Upgrade Notes; otherwise the PR title type decides, with # `!` (breaking) pulled out of the type groups first — same order the old @@ -126,3 +144,16 @@ for section in "${SECTIONS[@]}"; do echo fi done + +# Merged PRs the tool returned no note for (no release-note block in the +# body — e.g. everything merged before the block became mandatory). +# Listing them keeps the PR visible in the release instead of dropping +# it silently; the warning above tells the releaser to look. +if [[ -n "${MISSING}" ]] && [[ "${MISSING}" != "[]" ]]; then + echo "### PRs Without Release Notes" + echo + jq -r --argjson titles "${TITLES}" ' + .[] + | "- #\(.) \($titles[tostring] // "")"' <<<"${MISSING}" + echo +fi diff --git a/scripts/renovate/update-release-notes-checksum.sh b/scripts/renovate/update-release-notes-checksum.sh new file mode 100644 index 0000000000..1abfdb2e20 --- /dev/null +++ b/scripts/renovate/update-release-notes-checksum.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Called by Renovate postUpgradeTasks after a kubernetes/release bump in +# scripts/gather-release-notes.sh. Downloads the linux release-notes +# asset for the bumped version, checks it against the sha256 digest +# GitHub recorded for the asset, and only then updates +# RELEASE_NOTES_SHA256 in the script. +set -euo pipefail +source "$(dirname "${BASH_SOURCE[0]}")/lib-checksums.sh" + +FILE="scripts/gather-release-notes.sh" +ASSET="release-notes-amd64-linux" + +url=$(grep -oE "https://github\.com/kubernetes/release/releases/download/v[0-9.]+/${ASSET}" "${FILE}") \ + || die "no ${ASSET} download URL in ${FILE}" +VERSION="${url##*/v}" +VERSION="${VERSION%%/*}" + +artifact=$(fetch_cached "${url}") || die "failed to download ${url}" +computed=$(sha256sum "${artifact}" | cut -d' ' -f1) +[[ "${computed}" =~ ${SHA_RE} ]] || die "computed checksum is not a sha256 hex digest: '${computed}'" + +published=$(github_asset_digest kubernetes/release "v${VERSION}" "${ASSET}") \ + || die "could not get the published digest for ${url}" +[[ "${published}" =~ ${SHA_RE} ]] || die "published digest for ${url} is not a sha256 hex digest: '${published}'" +[[ "${published}" == "${computed}" ]] || die "checksum mismatch for ${url}: published ${published}, downloaded ${computed}" + +count=$(grep -c '^ local RELEASE_NOTES_SHA256=' "${FILE}" || true) +if [[ "${count}" != "1" ]]; then + die "expected exactly one 'local RELEASE_NOTES_SHA256=' line in ${FILE}, found ${count}" +fi +sed -i "s/^ local RELEASE_NOTES_SHA256=.*/ local RELEASE_NOTES_SHA256=${computed}/" "${FILE}" +grep -q "local RELEASE_NOTES_SHA256=${computed}" "${FILE}" || die "failed to update RELEASE_NOTES_SHA256 in ${FILE}" + +echo "updated RELEASE_NOTES_SHA256 to ${computed} (kubernetes/release v${VERSION})" diff --git a/skills/cutting-releases/SKILL.md b/skills/cutting-releases/SKILL.md index 31a670de2d..ef9cac3403 100644 --- a/skills/cutting-releases/SKILL.md +++ b/skills/cutting-releases/SKILL.md @@ -290,11 +290,16 @@ installs the binary as `fullsend-` so multiple versions can coexist. a shipped release is bad, cut a new patch or RC. Only a blocked final may be deleted (see "When a release run fails"). - **The changelog** is gathered from `release-note` blocks in merged PR - bodies (see COMMITS.md, "Release notes"). The release workflow runs the - Kubernetes `release-notes` tool over the tag range and passes the - result to GoReleaser via `--release-notes`, so PR bodies — not commit - subjects — are the source of release-note entries. NONE blocks are - skipped. The published body starts with a `## Changelog` header + bodies (see COMMITS.md, "Release notes"). A read-only + `gather-release-notes` job runs the Kubernetes `release-notes` tool + over the tag range and passes the result to the signing job (and then + GoReleaser via `--release-notes`) as an artifact, so PR bodies — not + commit subjects — are the source of release-note entries. NONE blocks + are skipped. The gather fails if a merged PR's body was edited after + merge (the published note would differ from the reviewed one); a + maintainer must review such edits before releasing. Merged PRs with + no block are listed under **PRs Without Release Notes** instead of + vanishing. The published body starts with a `## Changelog` header (prepended by the workflow so `prepend-release-highlights.sh` keeps working), followed by **Urgent Upgrade Notes** (PRs labeled `release-note-action-required`, applied automatically when a PR's From 99b8e0edaacd1270d8e234f6f5568411d6dd530b Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Thu, 26 Nov 2026 13:35:42 +0100 Subject: [PATCH 8/9] fix(release): match gather script to release-notes v0.23.0 semantics Drop the --required-author flag (removed upstream), pass --repo-path so the tool walks the workflow checkout instead of a nonexistent tempdir clone, and set START_SHA to the previous tag itself so the first-parent walk includes the first PR merged after it. Add a recovery path for the post-merge-edit block (release-note-edit-approved label), set GH_REPO in the label-sync job, route gather failures to notify-release-blocked, define the missing fail() in the render test, and refresh stale v0.17.1-era comments and docs. Assisted-By: glm-5-3(pi) Signed-off-by: Hector Martinez --- .github/workflows/release-note-check.yml | 3 ++ .github/workflows/release.yml | 5 +- scripts/gather-release-notes-test.sh | 41 +++------------ scripts/gather-release-notes.sh | 65 ++++++++++-------------- scripts/render-release-notes-test.sh | 9 ++++ skills/cutting-releases/SKILL.md | 3 +- 6 files changed, 51 insertions(+), 75 deletions(-) diff --git a/.github/workflows/release-note-check.yml b/.github/workflows/release-note-check.yml index 4e53e20eaf..5593c76019 100644 --- a/.github/workflows/release-note-check.yml +++ b/.github/workflows/release-note-check.yml @@ -90,6 +90,9 @@ jobs: - name: Sync action-required label env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # gh cannot infer the repository without a checkout (it ignores + # GITHUB_REPOSITORY), so tell it explicitly. + GH_REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }} ACTION_REQUIRED: ${{ needs.release-note-check.outputs.action-required }} run: | diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3cabf6ec14..f8c29bf310 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -301,13 +301,14 @@ jobs: # published the binary and Slack reported only the missing agents tag. # Now the whole release stops here, so it needs its own signal; # otherwise a blocked release is silent on Slack. - needs: [validate-agents, resolve-agents, recheck-tag] + needs: [validate-agents, resolve-agents, recheck-tag, gather-release-notes] if: >- github.event_name == 'push' && always() && (needs.validate-agents.result == 'failure' || needs.resolve-agents.result == 'failure' - || needs.recheck-tag.result == 'failure') + || needs.recheck-tag.result == 'failure' + || needs.gather-release-notes.result == 'failure') runs-on: ubuntu-24.04 timeout-minutes: 5 permissions: diff --git a/scripts/gather-release-notes-test.sh b/scripts/gather-release-notes-test.sh index 6aacd2d106..676bf026c9 100644 --- a/scripts/gather-release-notes-test.sh +++ b/scripts/gather-release-notes-test.sh @@ -1,11 +1,12 @@ #!/usr/bin/env bash # gather-release-notes-test.sh — Tests for the pure functions of -# gather-release-notes.sh (range math and merged-PR extraction). +# gather-release-notes.sh (merged-PR extraction). # # The full script needs the release-notes binary and an authenticated -# gh, so only the offline parts are exercised here: compute_start_sha -# (first-parent selection, the old-date trap, the re-tag fallback) and -# extract_merged_prs (merge commits and squash subjects). +# gh, so only the offline parts are exercised here: extract_merged_prs +# (merge commits and squash subjects). The START_SHA selection is a +# plain `git rev-parse PREV` (v0.23.0 stops its first-parent walk at the +# merge base of START_SHA and END_SHA, exclusive), so it needs no test. # # Run from the repo root: # bash scripts/gather-release-notes-test.sh @@ -48,9 +49,6 @@ assert_equals() { # A --- B(merge #1) --- C(squash #2) --- D(merge #3) <- TAG # \ # E (old-dated PR-branch commit for #1) -# -# E carries a commit date older than PREV, so an oldest-date START_SHA -# selection would open the window before PREV and re-list PR #1. build_repo() { git -C "${TMP}" init -q -b main git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "A" @@ -59,9 +57,7 @@ build_repo() { # PR #1: a branch with an old-dated commit, merged with a merge commit. git -C "${TMP}" checkout -q -b pr1 - # 2000-01-01: far older than PREV. - GIT_COMMITTER_DATE="2000-01-01T00:00:00Z" GIT_AUTHOR_DATE="2000-01-01T00:00:00Z" \ - git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "E" + git -C "${TMP}" -c user.email=t@t -c user.name=t commit -q --allow-empty -m "E" git -C "${TMP}" checkout -q main git -C "${TMP}" -c user.email=t@t -c user.name=t merge -q --no-ff -m "Merge pull request #1 from x/pr1" pr1 @@ -83,31 +79,6 @@ build_repo # temp repo. cd "${TMP}" -# --- compute_start_sha ---------------------------------------------------- - -# START_SHA must be the first first-parent commit after PREV (the #1 -# merge), not the old-dated PR-branch commit E. -EXPECTED_START=$(git -C "${TMP}" rev-list --first-parent --reverse v0.1.0..v0.2.0 | head -n1) -assert_equals "compute_start_sha picks the first first-parent commit after PREV" \ - "${EXPECTED_START}" "$(compute_start_sha v0.1.0 v0.2.0)" - -# START_SHA must not be E even though E is the oldest-dated commit in -# the range. -OLD_DATED=$(git -C "${TMP}" rev-list v0.1.0..v0.2.0 | while read -r c; do - printf '%s %s\n' "$(git -C "${TMP}" show -s --format=%ct "${c}")" "${c}" -done | sort -n | head -n1 | cut -d' ' -f2) -if [[ "$(compute_start_sha v0.1.0 v0.2.0)" != "${OLD_DATED}" ]]; then - ok "compute_start_sha ignores the old-dated PR-branch commit" -else - fail "compute_start_sha ignores the old-dated PR-branch commit" \ - "not ${OLD_DATED}" "${OLD_DATED}" -fi - -# Re-tag: PREV and TAG on the same commit falls back to PREV itself. -git -C "${TMP}" tag v0.2.0-same "$(git -C "${TMP}" rev-parse v0.1.0)" -assert_equals "compute_start_sha falls back to PREV on a re-tag" \ - "$(git -C "${TMP}" rev-parse v0.1.0)" "$(compute_start_sha v0.1.0 v0.2.0-same)" - # --- extract_merged_prs --------------------------------------------------- assert_equals "extract_merged_prs finds merge commits and squash subjects" \ diff --git a/scripts/gather-release-notes.sh b/scripts/gather-release-notes.sh index aa2c1865ca..5a3ffacb43 100644 --- a/scripts/gather-release-notes.sh +++ b/scripts/gather-release-notes.sh @@ -10,10 +10,11 @@ # # Writes OUTDIR/release-notes.md (with the "## Changelog" header the # release-highlights step expects) and OUTDIR/release-notes-body.md. -# Requires gh (authenticated) for PR title and edit-timestamp lookups. +# Requires gh (authenticated) for PR title, label and edit-timestamp +# lookups. # -# The range math and merged-PR extraction live in functions below so -# gather-release-notes-test.sh can exercise them offline (the full run +# The merged-PR extraction lives in a function below so +# gather-release-notes-test.sh can exercise it offline (the full run # needs the release-notes binary and an authenticated gh). set -euo pipefail @@ -34,25 +35,6 @@ install_release_notes() { sudo mv "${outdir}/release-notes" /usr/local/bin/release-notes } -# compute_start_sha PREV TAG — print the first first-parent commit after -# PREV on the path to TAG. -# -# The tool lists commits from START_SHA's commit date onward (inclusive). -# Use the first first-parent commit after PREV: picking the oldest-dated -# commit in the range would open the window before PREV (PR-branch -# commits can carry dates older than PREV) and re-list PRs from the -# previous release. When PREV and TAG share a commit (a re-tag), fall -# back to PREV itself. -compute_start_sha() { - local prev=$1 tag=$2 range - range=$(git rev-list --first-parent --reverse "${prev}..${tag}") - if [[ -n "${range}" ]]; then - head -n1 <<<"${range}" - else - git rev-list -n1 "${prev}" - fi -} - # extract_merged_prs PREV TAG — print the PR numbers merged in the range, # one per line, sorted and unique. Merge commits say "Merge pull request # #N"; squash-merge subjects end with "(#N)". @@ -63,9 +45,9 @@ extract_merged_prs() { | sort -u } -# fetch_pr_meta PR — print a JSON object with the PR's title, lastEditedAt -# and mergedAt (one GraphQL call). lastEditedAt is null when the body was -# never edited. +# fetch_pr_meta PR — print a JSON object with the PR's title, +# lastEditedAt, mergedAt and label names (one GraphQL call). +# lastEditedAt is null when the body was never edited. fetch_pr_meta() { local pr=$1 gh api graphql \ @@ -75,6 +57,9 @@ fetch_pr_meta() { title lastEditedAt mergedAt + labels(first: 100) { + nodes { name } + } } } }' \ @@ -96,23 +81,25 @@ main() { fi echo "Gathering notes from ${PREV} to ${TAG}" + # v0.23.0 walks first parents from END_SHA and stops at the merge base + # of END_SHA and START_SHA (exclusive), so START_SHA must be PREV + # itself: every commit after PREV up to TAG is then included, and the + # first PR merged after the previous tag keeps its note. local START_SHA END_SHA - START_SHA=$(compute_start_sha "${PREV}" "${TAG}") + START_SHA=$(git rev-parse "${PREV}") END_SHA=$(git rev-list -n1 "${TAG}") - # The tool reads its range and branch from these env vars. Use the tag's - # SHA as the listing ref (the `sha` parameter accepts a SHA): listing - # from main would include PRs merged to main after the tag but dated - # inside the window. --required-author="" includes bot-authored PRs - # (agents open many of our PRs). + # The tool reads its range from these env vars and walks a local clone + # (v0.23.0 has no --required-author flag and no date window; it opens + # the repo at --repo-path, which defaults to a tempdir clone that does + # not exist here). export START_SHA END_SHA - export BRANCH="${END_SHA}" # Gather as JSON, then render with our own script. The tool credits a # commit to any PR cited as "(#N)" in its message, so PRs from earlier # releases can appear; the renderer keeps only PRs actually merged in # the range (first-parent commits between PREV and TAG) and groups notes # by PR title type, mirroring the old GoReleaser changelog layout. release-notes generate \ - --required-author="" \ + --repo-path "$(git rev-parse --show-toplevel)" \ --dependencies=false \ --format json \ --output "${OUTDIR}/release-notes.json" \ @@ -133,19 +120,23 @@ main() { # The release-note check validates the body only before merge. After # merge the author (including a fork contributor) can still edit the # body, replacing a reviewed note with arbitrary markdown. Refuse to - # publish a note whose body was edited after the merge; a maintainer - # must review the edit (revert it or re-approve it) before releasing. + # publish a note whose body was edited after the merge. Reverting the + # edit does not clear lastEditedAt, so the recovery path is explicit: + # a maintainer reviews the edited body and adds the + # release-note-edit-approved label to the PR. if jq -e ' .lastEditedAt != null and .mergedAt != null and .lastEditedAt > .mergedAt - ' >/dev/null <<<"${meta}"; then + ' >/dev/null <<<"${meta}" \ + && ! jq -e '[.labels.nodes[].name] + | index("release-note-edit-approved")' >/dev/null <<<"${meta}"; then edited_after_merge+=("${pr}") fi done < "${OUTDIR}/merged-prs.txt" if [[ ${#edited_after_merge[@]} -gt 0 ]]; then # PR numbers are numeric, so interpolating them needs no # workflow-command escaping. - echo "::error::PRs whose body was edited after merge (the published note would differ from the reviewed one): ${edited_after_merge[*]}. A maintainer must review the edits before releasing." + echo "::error::PRs whose body was edited after merge (the published note would differ from the reviewed one): ${edited_after_merge[*]}. A maintainer must review each edit and add the release-note-edit-approved label to the PR before releasing." exit 1 fi bash "${SCRIPT_DIR}/render-release-notes.sh" \ diff --git a/scripts/render-release-notes-test.sh b/scripts/render-release-notes-test.sh index 6d4d84550f..04369c92cc 100755 --- a/scripts/render-release-notes-test.sh +++ b/scripts/render-release-notes-test.sh @@ -13,6 +13,15 @@ trap 'rm -rf "${TMP}"' EXIT FAILURES=0 +fail() { + echo "FAIL — $1" + echo "--- expected ---" + printf '%s\n' "$2" + echo "--- actual ---" + printf '%s\n' "$3" + FAILURES=$((FAILURES + 1)) +} + check() { local desc=$1 expected=$2 actual actual=$("${SCRIPT}" "${TMP}/notes.json" "${TMP}/merged.txt" "${TMP}/titles.tsv") diff --git a/skills/cutting-releases/SKILL.md b/skills/cutting-releases/SKILL.md index ef9cac3403..d88e8eac60 100644 --- a/skills/cutting-releases/SKILL.md +++ b/skills/cutting-releases/SKILL.md @@ -297,7 +297,8 @@ installs the binary as `fullsend-` so multiple versions can coexist. commit subjects — are the source of release-note entries. NONE blocks are skipped. The gather fails if a merged PR's body was edited after merge (the published note would differ from the reviewed one); a - maintainer must review such edits before releasing. Merged PRs with + maintainer must review such edits and add the + `release-note-edit-approved` label to the PR before releasing. Merged PRs with no block are listed under **PRs Without Release Notes** instead of vanishing. The published body starts with a `## Changelog` header (prepended by the workflow so `prepend-release-highlights.sh` keeps From 4da7e16bc72c6c7fa50a0737d0b869b40ab46e0a Mon Sep 17 00:00:00 2001 From: Hector Martinez Date: Thu, 26 Nov 2026 13:38:17 +0100 Subject: [PATCH 9/9] fix(release): peel annotated tag to commit SHA for START_SHA The gather-dry-run on the head commit failed with 'finding commit of merge base SHA: object not found': git rev-parse on an annotated tag returns the tag object SHA, which the release-notes tool cannot resolve as a commit. Peel with ^{commit}. Assisted-By: glm-5-3(pi) Signed-off-by: Hector Martinez --- scripts/gather-release-notes.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/gather-release-notes.sh b/scripts/gather-release-notes.sh index 5a3ffacb43..be8cdc6d37 100644 --- a/scripts/gather-release-notes.sh +++ b/scripts/gather-release-notes.sh @@ -86,7 +86,9 @@ main() { # itself: every commit after PREV up to TAG is then included, and the # first PR merged after the previous tag keeps its note. local START_SHA END_SHA - START_SHA=$(git rev-parse "${PREV}") + # ^{commit} peels annotated tags to their commit SHA; the tool's + # CommitObject call fails on a tag object. + START_SHA=$(git rev-parse "${PREV}^{commit}") END_SHA=$(git rev-list -n1 "${TAG}") # The tool reads its range from these env vars and walks a local clone # (v0.23.0 has no --required-author flag and no date window; it opens