Skip to content

feat(release/auto-changelog): preserve finalized changelog history when merging previous releases - #300

Open
HowardBraham wants to merge 1 commit into
mainfrom
merge-previous-releases
Open

HowardBraham wants to merge 1 commit into
mainfrom
merge-previous-releases

Conversation

@HowardBraham

@HowardBraham HowardBraham commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

References

  • This is part of the release-changelog automation, splitting it into smaller reviewable PRs.

Explanation

Current state

When a new release/X.Y.Z branch is created, merge-previous-releases.sh merges every older active release branch into it with git merge -s ours. That records the ancestry without duplicating code, but it also keeps the destination's files. If an older release has already published its finalized changelog section (## [13.54.0] plus its [13.54.0]: … link), the new branch never gets it, and the next release's changelog is generated without it.

Solution

After each -s ours merge, the script now runs a new merge-previous-release-changelog.mts. It does the following:

  • It copies the older release's ## [version] section and its link reference from the source CHANGELOG.md into the destination, in newest-first order.
  • It then amends the merge commit to include the change.
  • It edits the changelog as plain text, not through a parser, and it leaves the destination untouched, with a warning, when it isn't sure. That covers a missing or duplicated source section, a destination that already has the release, and any error.

The script is TypeScript that Node runs directly with no build step. Native .mts support needs Node 22.18 or later, so this PR also moves the repo from Node 20 to 22:

  • .nvmrc goes from v20 to v22.23.4.
  • engines.node and the constraints.pro rule go from >=20.0.0 to >=22.18.0.
  • The merge action gains a setup-node step that reads .nvmrc. Before this it ran on whatever Node the runner had.

Impact of the Node bump

.nvmrc feeds seven actions through node-version-file (check-changelog, draft-segment-schema-pr, flaky-test-report, playwright-test-health-report, post-merge-validation, publish-slack-release-testing-status and the merge action), plus the post-relay-subsidy-balance workflow. Their consumers move from Node 20 to 22. Actions with their own pinned Node (stable-sync, remove-rca-needed-label-sheets, setup-e2e-env) aren't affected. Reviewers should confirm that moving those actions to Node 22 is acceptable.

Other changes

  • Tests: merge-previous-releases.test.mts runs the real shell script against a throwaway origin and clone, with a fake gh. It covers a preserved release, an ambiguous source, and a destination that already has the release.
  • yarn test: it now runs every *.test.{mjs,mts} file with one node --test. This also picks up playwright-test-health-report/lib/report-health.test.mjs, which was never wired into yarn test.
  • Tooling: no new scripts or configs. The .mts files are added to the existing tsc (via include) and lint:eslint runs, plus two small ESLint overrides. lint:eslint stays two commands, because ESLint ignores dot-directories.

Testing

  • Local: tsc, lint:eslint and node --test pass on Windows and on Linux (Ubuntu with Node 22.23.4, no git identity configured).
  • Fork, with the action pinned to a SHA: on consensys-test/metamask-extension-howard, a new release/ branch merged an older active release. setup-node installed 22.23.4 and the log showed Inserted finalized 999.999.999 changelog history. The section was byte-identical to the source, sat in version order, and only CHANGELOG.md changed. A branch whose destination already had the section was left byte for byte. Runs: 40046194251, 40046722723, 40059428200.
  • Not tested: I only exercised the merge action. The other six actions haven't run on Node 22 in a fork. The Node 22 move relies on tsc, ESLint, the constraints check and the unit tests passing, not on those actions running.

Note

Medium Risk
Touches release-branch merge automation and amends merge commits on CHANGELOG.md, plus a repo-wide Node 20→22 bump that affects multiple GitHub Actions consumers of .nvmrc.

Overview
Fixes lost release changelog sections when older active release branches are merged into a new release/X.Y.Z branch with git merge -s ours. After each ancestry-only merge, merge-previous-release-changelog.mts copies the source branch’s finalized ## [version] block and [version]: link from CHANGELOG.md into the destination in version order, then merge-previous-releases.sh amends the merge commit when CHANGELOG.md changes. Ambiguous or unsafe cases (duplicate headings, section already present, errors) warn and leave the destination unchanged so the merge does not fail.

The repo requires Node ≥22.18 (.nvmrc v22.23.4, engines, constraints.pro) so the .mts helper runs without a build step; the merge-previous-releases action adds setup-node from github-tools/.nvmrc. Tooling adds lint/tsc coverage for .github/scripts/**/*.mts, broadens yarn test to all .github/**/*.test.{mjs,mts}, and adds integration tests that exercise the real shell script with a fake gh.

Reviewed by Cursor Bugbot for commit d0e407b. Bugbot is set up for automated code reviews on this repo. Configure here.

@HowardBraham HowardBraham self-assigned this Oct 24, 2026
@HowardBraham
HowardBraham force-pushed the merge-previous-releases branch from ac9c6d1 to 884e1f4 Compare October 24, 2026 03:54
@HowardBraham HowardBraham changed the title feat(release): preserve finalized changelog history when merging previous releases feat(release/auto-changelog): preserve finalized changelog history when merging previous releases Oct 24, 2026
@HowardBraham
HowardBraham marked this pull request as ready for review October 24, 2026 03:59
@HowardBraham
HowardBraham added this pull request to stack #302 October 25, 2026 22:33
@HowardBraham
HowardBraham force-pushed the merge-previous-releases branch from 884e1f4 to d0e407b Compare October 26, 2026 05:19

This branch has not been deployed

No deployments
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