Skip to content

Add changelog fragments in .changelog/ - #20592

Draft
RobinMalfait wants to merge 5 commits into
mainfrom
robin/changelog-fragments
Draft

RobinMalfait wants to merge 5 commits into
mainfrom
robin/changelog-fragments

Conversation

@RobinMalfait

Copy link
Copy Markdown
Contributor

This PR adds changelog fragments, so that pull requests do not conflict with each other in CHANGELOG.md.

Each pull request that needs a changelog entry adds a Markdown file to .changelog/, for example .changelog/vite-full-reload.md:

### Fixed

- Prevent `@tailwindcss/vite` from doing a full page reload for external files (e.g. `.php` files)

The entry needs no link to the pull request. The script finds the pull request that added the fragment in the git history, and adds its link. An entry that already has a [#…](…) link keeps it.

Changes

  • scripts/changelog.mjs has three commands (also as pnpm changelog):
    • pnpm --silent changelog prints CHANGELOG.md, with the entries of the fragments in [Unreleased].
    • pnpm changelog check validates the fragments and the [Unreleased] section.
    • pnpm changelog release <version> [<date>] moves the entries into a new ## [<version>] - <date> section, updates the compare links, and deletes the fragments.
  • The entries that are already in [Unreleased] come first. The entries of the fragments follow, in the order in which their pull requests merged. Thus the current entries in CHANGELOG.md keep working during the transition.
  • A new Changelog job in ci.yml runs check. It only needs Node.js, and it is not a required check.
  • A new changelog.yml workflow pushes the preview to the changelog branch after each merge into main that changes the fragments, CHANGELOG.md or the script. The branch has one commit with only CHANGELOG.md. [Unreleased] in CHANGELOG.md links to this preview.
  • .changelog/README.md and CONTRIBUTING.md explain the format.
  • The tests are in scripts/changelog.test.mjs, in a new scripts vitest project.

Test plan

  • pnpm vitest run --project scripts
  • node ./scripts/changelog.mjs check
  • After the merge, run the Changelog preview workflow and check the changelog branch.

…CHANGELOG.md`

The script has three commands:

- `preview` (the default) prints the full `CHANGELOG.md`, with the
  entries of the fragments in `[Unreleased]`.
- `check` validates the fragments and the `[Unreleased]` section.
- `release <version> [date]` writes the `## [<version>] - <date>`
  section, a new `[Unreleased]` section and the compare links, and
  deletes the fragments.

An entry without a `[#…](…)` link gets the link of the pull request
that added the fragment. The entries keep the order in which the pull
requests merged, after the entries that are already in `[Unreleased]`.

The tests run with vitest, in a new `scripts` project.
The `Changelog` job only needs Node.js, because the script has no
dependencies. It is not a required check.
After each merge into `main` that changes `.changelog/`,
`CHANGELOG.md` or the script, the workflow force-pushes one commit with
the preview of `CHANGELOG.md` to the `changelog` branch. The preview
has the entries of the fragments in `[Unreleased]`.

The checkout has the full history without the file contents, so that
the script finds the pull request that added each fragment. A push with
the `GITHUB_TOKEN` starts no other workflows.
The line is the intro of `[Unreleased]`: the preview leaves it out, and
`changelog release` keeps it in the new `[Unreleased]` section.
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.

1 participant