Skip to content

feat(create-release-branch): apply a Changesets release - #169

Draft
GuillaumeRx wants to merge 1 commit into
gr/crb-cs-04-planfrom
gr/crb-cs-05-apply
Draft

GuillaumeRx wants to merge 1 commit into
gr/crb-cs-04-planfrom
gr/crb-cs-05-apply

Conversation

@GuillaumeRx

@GuillaumeRx GuillaumeRx commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Explanation

Writes a planned release to the project. Nothing in create-release-branch uses this code yet.

applyChangesetsRelease first checks that .changeset has no uncommitted changes. This check is also exported as checkChangesetDirectory, so that the mode can run it earlier. It also checks that the changelog of each released package can be parsed, has no entries in Unreleased, and can take a new release section. If a check fails, it throws a ChangesetsSetupError before it changes any file. Then it:

  1. Runs applyReleasePlan to bump the versions, write the release sections, and delete the used Changesets. applyReleasePlan writes to console.error when it cannot generate a changelog, and then throws. The tool drops these console messages and reports the error as a ChangesetsApplyError. @metamask/apply-release-plan does not change.
  2. Rewrites the changelogs of the released packages with @metamask/auto-changelog. This adds the link of the new release section and removes the empty Unreleased section.
  3. Writes the new root version to the root package.json. applyReleasePlan only updates the dependency ranges of the root, not its version. The root changelog does not change.
  4. Restores the unused part of each partly used Changeset.

If a step fails, it throws a ChangesetsApplyError. The error tells the user to run git stash --include-untracked and try again.

Changesets mode releases only the Changesets. It does not move Unreleased entries into the release. The error for Unreleased entries asks the user to move them into a Changeset and commit it, or to remove them.

@metamask/changesets-changelog no longer fails if the subject of the commit that added a Changeset has no pull request number. It writes the entry without a link. An example is a Changeset that the maintainer commits on the release branch. The maintainer can add the link by hand. It still fails if it cannot find the commit.

New dependency: @metamask/apply-release-plan. It is not published yet. It must be published before or with create-release-branch.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

@GuillaumeRx
GuillaumeRx added this pull request to stack #171 November 12, 2026 14:07
@GuillaumeRx
GuillaumeRx force-pushed the gr/crb-cs-05-apply branch 2 times, most recently from 384d067 to a852273 Compare November 12, 2026 15:41
@GuillaumeRx
GuillaumeRx force-pushed the gr/crb-cs-05-apply branch 2 times, most recently from 7f04499 to 2086f30 Compare November 12, 2026 17:33
Add applyChangesetsRelease, which writes a planned Changesets release to
the project. It checks the .changeset directory and the changelogs first,
then runs applyReleasePlan, rewrites the changelogs of the released
packages, writes the new root version, and restores the Changesets that
the release only partly consumed. The messages that applyReleasePlan
writes to the console when it fails are dropped, because the error that
it throws already describes the failure.

Changesets mode releases only the Changesets. A released package whose
changelog has entries in Unreleased stops the release before any file
changes. The rewrite with auto-changelog adds the link reference
definition of the new release section and removes the empty Unreleased
section. The root changelog does not change.

@metamask/changesets-changelog now writes an entry without a pull request
link if the commit subject of its changeset has no pull request number,
for example a Changeset committed on the release branch. The maintainer
can add the link by hand.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant