Skip to content

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

Merged
HowardBraham merged 2 commits into
mainfrom
merge-previous-releases
Oct 28, 2026
Merged

HowardBraham merged 2 commits 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

@mcmire mcmire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't review the script itself as I don't have much context on it, but I left some minor suggestions below.

As far as the risk to other repos goes, this looks pretty safe to me. I don't believe other repos use the merge-previous-releases action (or at least, I don't recognize it).

Comment thread .github/scripts/tests/merge-previous-releases.test.mts
Comment thread .eslintrc.js Outdated
Comment thread .eslintrc.js
Comment thread .github/scripts/merge-previous-release-changelog.mts

@mcmire mcmire left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@HowardBraham
HowardBraham merged commit ad357f6 into main Oct 28, 2026
10 checks passed
@HowardBraham
HowardBraham deleted the merge-previous-releases branch October 28, 2026 19:00
JadeCong pushed a commit to CloudEngineHub/metamask-extension that referenced this pull request Oct 29, 2026
…MetaMask#47463)

## **Description**

This is the very last step in a chain of PRs to turn on fully-autonomous
CHANGELOG generation in Extension.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

### Previous PRs in the chain

#### release-tools/auto-changelog
MetaMask/release-tools#127
MetaMask/release-tools#130

#### github-tools
MetaMask/github-tools#300
MetaMask/github-tools#301
MetaMask/github-tools#303

<!--## **Manual testing steps**
## **Screenshots/Recordings**
## **Pre-merge author checklist**
## **Pre-merge reviewer checklist**-->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Workflow-only change that adds a CI secret env var and removes an
action input; no runtime extension code or user-facing behavior changes.
> 
> **Overview**
> Turns on the **AI changelog proofreader** for release changelog
automation by passing **`AI_ANALYZER_LITELLM_KEY`** into the
`update-release-changelog` GitHub Action (same LiteLLM secret pattern as
other AI workflows).
> 
> Also **drops the explicit `previous-version-ref: 'null'`** input so
previous-version resolution is handled by the updated action rather than
being hard-coded in this repo.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
c801241. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
darkwing pushed a commit to darkwing/metamask-mobile that referenced this pull request Oct 29, 2026
…MetaMask#38444)

## **Description**

This is the very last step in a chain of PRs to turn on fully-autonomous
CHANGELOG generation in Mobile.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

### Previous PRs in the chain

#### release-tools/auto-changelog
MetaMask/release-tools#127
MetaMask/release-tools#130

#### github-tools
MetaMask/github-tools#300
MetaMask/github-tools#301
MetaMask/github-tools#303

<!--## **Manual testing steps**
## **Screenshots/Recordings**
## **Pre-merge author checklist**
## **Pre-merge reviewer checklist**-->

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes how release and OTA hotfix changelogs are produced in CI;
misconfiguration could break changelog PRs or tags, though behavior is
intended to match the removed script via github-tools v1.
> 
> **Overview**
> Mobile release changelog automation no longer runs the local
**`run-update-release-changelog-mobile.sh`** wrapper or manual
**github-tools** checkout, Node setup, and **`yarn`** steps.
**`create-release-pr.yml`** (OTA hotfix path) and
**`update-release-changelog.yml`** now call
**`MetaMask/github-tools/.github/actions/update-release-changelog@v1`**,
which owns branch checkout, version derivation from **`release/X.Y.Z`**
/ **`release/X.Y.Z-ota`**, and concurrent Runway updates on the release
branch.
> 
> This PR also threads **`AI_ANALYZER_LITELLM_KEY`** from
**`auto-create-release-pr.yml`** into **`create-release-pr.yml`** as an
optional reusable-workflow secret and passes it into both changelog
action steps so the new AI changelog proofreader can run during
autonomous **`CHANGELOG.md`** generation.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
1abeae5. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: howard <howard@example.com>
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