Skip to content

build(release): one changelog file per PR in changelog.d/, assembled at release #2113 - #2119

Merged
nc9 merged 3 commits into
mainfrom
build/changelog-d-2113
Nov 18, 2026
Merged

nc9 merged 3 commits into
mainfrom
build/changelog-d-2113

Conversation

@nc9

@nc9 nc9 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Every user-visible PR used to add its bullet to the same ## [Unreleased] block of CHANGELOG.md, so each merge put every other open PR into conflict. With this change, each PR adds its own file under changelog.d/, and the release bump PR assembles the files into CHANGELOG.md.

Refs #2113 (planning closes it once this lands at a quiet point; see "Landing" below).

The scheme

  • changelog.d/<issue>-<short-name>.<section>.md, where <section> is added, changed, fixed, security or docs. The file holds the bullet exactly as it would read under that section. changelog.d/README.md documents it.
  • scripts/changelog.ts assembles the files (unreleased, release, convert and check subcommands). bun run changelog, bun run changelog:release <v> and bun run changelog:convert call it.
  • make release (scripts/release.ts) now assembles the entries into the ## vX.Y.Z (date) section inside the version bump PR it already opens, and deletes the files in that same commit.

Acceptance criteria

  • One file per PR, no CHANGELOG.md edit, no conflicts in either order. A PR adds changelog.d/<issue>-<name>.<section>.md (changelog.d/README.md, AGENTS.md:235). Each PR adds a different path, so two PRs never touch the same lines. Tested in scripts/test-changelog-entries.sh ("a PR that adds an entry file passes").
  • Release assembly, stable section order, files removed in the same change. scripts/changelog.ts:25 (SECTIONS = Added, Changed, Fixed, Security, Docs), :73 renderSections, :98 insertRelease, :124 release (writes the section, then deletes the files). scripts/release.ts:242 runs it in the bump PR commit. Tests in scripts/changelog.test.ts:
    • two entries in one section: "two entries in one section land under one heading, in file-name order, and the files are deleted";
    • empty section: "an empty section gets no heading, and sections follow Added, Changed, Fixed, Security, Docs";
    • unknown section name fails: "a file with an unknown section name fails and nothing is written or deleted".
  • CI changelog check. scripts/check-changelog-entries.sh validates entry names against SECTIONS (:19) and fails a CHANGELOG.md edit that adds no new version heading (:65). The CI "Changelog guard" job runs check-released-changelog.sh, which now ends by running this guard (scripts/check-released-changelog.sh:140). I left ci.yml unchanged because the push token has no workflow scope. Tests in scripts/test-changelog-entries.sh: "a contributor-only change with no entry passes", "a PR that adds an entry file passes", "a direct CHANGELOG.md edit outside a release fails", "an unknown section name fails", "a release that adds a new version heading may write CHANGELOG.md". scripts/test-released-changelog.sh:129 checks that the CI entrypoint actually runs the guard, and it fails if the hook-up line is removed (checked by deleting it). A base that still has ## [Unreleased] skips only the direct-edit part, so this switch PR passes its own guard.
  • Every [Unreleased] bullet carried over. Before: 22 bullets under ## [Unreleased] on main 3ca69f59 (Changed 4, Added 15, Fixed 3, in four ### blocks including a duplicated ### Changed). After: 22 files in changelog.d/, no ## [Unreleased] left. diff <(bullets on main | sort) <(cat changelog.d/*.md | sort) gives no output, so the text is identical: none lost, none duplicated. bun run changelog | grep -c '^- ' prints 22. Two bullets (repo#1858 and repo#3360) landed on main while this branch was open. Rebases carried them with the same addedBullets logic that convert uses. Any bullet that lands before merge needs the same carry-over.
  • Consumers of [Unreleased], each updated:
    • scripts/check-released-changelog.sh: the "exactly one [Unreleased] heading" and header-bullet checks are replaced by "no [Unreleased] heading", the failure text points at changelog.d/, and it runs the entries guard. Test: scripts/test-released-changelog.sh, whose fixture drops [Unreleased], with new cases for an [Unreleased] heading failing and for the CI entrypoint.
    • scripts/extract-changelog.awk: logic unchanged. The [Unreleased] boundary stays harmless, and the comment now says why. Test: scripts/test-changelog-extraction.sh still passes.
    • .github/workflows/release.yml ("Resolve release notes"): unchanged. It extracts the ## vX.Y.Z section, which make release now writes into the bump PR.
    • scripts/release.ts: the preflight reads changelog.d/. When the version has no section and entries exist, the bump PR assembles them. The abort message points at changelog.d/.
    • .github/workflows/ci.yml "Changelog guard" job: unchanged file, the new check is reached through check-released-changelog.sh.
    • scripts/ci-classify.sh and scripts/test-ci-classify.sh: a changelog.d/*-only change runs no jobs (the guard job is not path-gated), and the new tooling files are release inputs.
    • package.json test:release and Makefile test-release-tooling: these now run the new tests.
    • CHANGELOG.md header prose, and AGENTS.md (see below).
    • Outside this repo: the private monorepo's plans/releases.md still describes renaming [Unreleased]. That one is flagged to the maintainer for a private follow-up.
  • One documented command prints the assembled unreleased section: bun run changelog (package.json:16, scripts/changelog.ts:277), documented in changelog.d/README.md, CHANGELOG.md header and AGENTS.md. Test: "the unreleased preview prints the same sections without touching anything".
  • Conversion script. bun run changelog:convert [--base origin/main] (scripts/changelog.ts:249; addedBullets :175, restoreUnreleased :193). It takes only the bullets the branch added against the merge base, writes one file per bullet with the same text, and puts the branch's ## [Unreleased] block back to the merge base's. An unrebased branch has no copy of the script yet, so the README shows how to run main's copy. Tests: "only the bullets the branch added are taken, with their section and exact text", "files hold the same text and CHANGELOG.md goes back to the base block", "a bullet under an unknown heading fails and writes nothing". End to end, I ran it on a worktree of old main with one added bullet: it wrote changelog.d/9999-...fixed.md, git diff origin/main -- CHANGELOG.md was empty, and after the documented squash the branch diff was only the new file.
  • AGENTS.md. New-rule checklist step 8 (AGENTS.md:151) and the PR rules (AGENTS.md:235) describe the changelog.d/ file. The paragraph about CHANGELOG rebase conflicts is removed.

Landing

  • Land this at a quiet point. Every open PR that still adds a CHANGELOG.md bullet then fails the changelog guard until it is converted (changelog.d/README.md, "Converting an open pull request"). Any bullet that merges to main before this PR must be carried over the same way at rebase time.
  • I could not push the ci.yml change (the token has no workflow scope), so the guard runs from the existing job. A maintainer may later add a named Check changelog entries step to the changelog-guard job: bash scripts/check-changelog-entries.sh "$BASE".

CodeQL

The first push raised two high alerts in scripts/changelog.ts: a regex built from the version argument, with incomplete escaping. The fix commit validates the version (X.Y.Z or X.Y.Z-pre.N) and matches existing headings by exact token instead. Test: "a version argument that is not X.Y.Z or X.Y.Z-pre.N is refused before anything changes".

Verification

  • bun run test:release (the CI "Release tooling tests" step) exits 0: extraction smoke test OK, released changelog tests OK, changelog entries guard tests OK, 36 pass / 0 fail (changelog.test.ts plus release-version.test.ts).
  • make test-release-tooling: 44 pass / 0 fail.
  • bash scripts/check-released-changelog.sh origin/main (the CI "Changelog guard" step) exits 0: "changelog entries OK (22 in changelog.d/)".
  • bash scripts/test-ci-classify.sh: all 42 cases pass. bun run scripts/test-suites.ts --check: OK.
  • With this commit as base, a direct CHANGELOG.md edit fails, adding a file passes, and a contributor-only change passes.
  • oxfmt --check and oxlint are clean on the new TS files. tsgo reports no errors in changelog.ts or changelog.test.ts. The errors it shows in release.ts are pre-existing, in untouched functions (promptChannel, promptBumpType); root scripts are not typechecked in CI.

Docs: none (docs/ has no changelog process page). Skill: none (the squirrelscan agent skill does not describe contributing changelog entries).

Comment thread scripts/changelog.ts Fixed
Comment thread scripts/changelog.ts Fixed
@nc9
nc9 force-pushed the build/changelog-d-2113 branch from bbe320d to 633c5c1 Compare November 17, 2026 23:24
nc9 added 3 commits November 18, 2026 11:59
…gex from the version argument #2113

Signed-off-by: Nik Cubrilovic <[email protected]>
…elog.d/; version message and merge-base option nits #2113

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the build/changelog-d-2113 branch from 633c5c1 to 01f7f02 Compare November 18, 2026 01:00
@nc9
nc9 marked this pull request as ready for review November 18, 2026 04:25
@nc9
nc9 merged commit 3389803 into main Nov 18, 2026
16 checks passed
@nc9
nc9 deleted the build/changelog-d-2113 branch November 18, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants