Skip to content

build(release): publish stable releases from main with changesets - #70

Draft
erunion wants to merge 2 commits into
mainfrom
erunion/changesets-release-dd7d
Draft

erunion wants to merge 2 commits into
mainfrom
erunion/changesets-release-dd7d

Conversation

@erunion

@erunion erunion commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Summary

Stable releases of @readme/cli move from publish.sh to the changesets flow that rdme publishes from main, including the tag-repair behavior now on rdme main.

Merging a feature pull request does not publish a new version. A change ships when someone merges the pull request titled build(release): vX.Y.Z. Every push to main checks whether npm already has the version in package.json. If it does not, that version is published from the first-parent commit that introduced it. A later merge that still carries that version is not the release commit, and an empty changeset does not skip the unpublished version. select-mode is not part of that decision: an empty changeset makes it return none, and GitHub can cancel the waiting run of the version merge when a newer push arrives. A prerelease is skipped instead of failing the job.

  • Changesets replaces publish.sh. There are no prereleases.
  • .github/workflows/release.yml is the trusted-publisher workflow. The publish job is the only job with id-token: write. It does not set NPM_TOKEN, NODE_AUTH_TOKEN, or registry-url, and it does not use a GitHub Environment. Release jobs use Node 24. That release ships npm 11.5.1 or newer, which trusted publishing requires.
  • The version job uses changesets/action/version@v2 when a changeset requests a release. Its github-token input and GITHUB_TOKEN environment variable are both RELEASE_GH_TOKEN. @changesets/changelog-github reads GITHUB_TOKEN while changeset version writes the changelog. The combined changesets/action throws if those two values differ.
  • release:version runs npm install --package-lock-only --ignore-scripts after changeset version, then npm run build:gha. Changesets updates package.json and leaves package-lock.json on the previous version. The GitHub Action bundle is committed, so the release pull request rebuilds it.
  • main publishes a stable version, including 0.x, on the latest dist-tag. This repo has no maintenance branch, so there is no v9 / release-v9 path.
  • After the version action writes its static title, bin/set-release-pr-title.js renames the pull request to build(release): vX.Y.Z from the version just written. A later bump renames it again. The job then adds the release label.
  • The publish plan records finish separately from whether this run calls npm. finish stays true while the version tag, the unprefixed tag, the floating major tag, or the GitHub release is missing, including when npm already has the version. The plan step sets GH_TOKEN so gh release view can see a release that already exists. Without that token, a finished release looks missing and the tags job runs on every push.
  • The tags job stays on the workflow commit and passes the release commit to the tag and GitHub release scripts. Tags point at the published commit, and a repair runs the scripts from this run. A rerun of an older release does not move the floating major tag backward, including when another artifact is missing or the remote version cannot be read. Once the tag and release exist, later pushes do not run the tags job.
  • The same job pushes vX.Y.Z, the unprefixed tag, and the floating major tag (v0 while the package is 0.x, v1 from 1.0.0), then opens the GitHub release. The publish action does not tag github.sha, because that can be a later commit.
  • Release scripts compare real paths before running, so a symlinked checkout still runs instead of exiting 0.
  • package.json files lists bin/readme.js, bin/build-gha.js, and bin/git-format.js instead of the whole bin directory, so the release scripts are not in the npm tarball. CHANGELOG.md is included.
  • One patch changeset is pending: "Publish stable releases from main with changesets." The version pull request moves 0.5.0 to 0.5.1. Changelog headings stay ## 0.5.0. A heading like ## [0.5.0](...) is ignored, and the next entry would be written further down the file.

After this merges

Do these in order. They are repository settings, not part of this change.

  1. Add a release label. The version job applies it and fails if the label is missing.
  2. Add a RELEASE_GH_TOKEN secret that can open pull requests, push commits, and push tags.
  3. Configure npm trusted publishing for @readme/cli, bound to .github/workflows/release.yml on main.
  4. Merging this pull request opens the release pull request. Merging that publishes 0.5.1.
  5. After 0.5.1 shows _npmUser.name of GitHub Actions and dist.attestations, delete any NPM_TOKEN secret and set publishing access to require two-factor authentication and disallow tokens.

Test plan

  • npm test (lint, oxfmt, schemas check, 346 tests)
  • npx vitest run test/bin (44 tests), including a missing tag, a missing GitHub release, a floating major tag on an older version, a floating major tag already on a newer version, an unreadable remote version, a finished release, a skipped prerelease, and reading package.json from the release commit after HEAD has moved on
  • After this merges, merge the release pull request and confirm npm view @readme/cli@0.5.1 was published by GitHub Actions with attestations
Open in Web Open in Cursor 

Replace the local publish.sh flow with the changesets release workflow.
Merging a change does not publish. It updates a release pull request, and
merging that publishes @readme/cli from the commit that introduced the version.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5RetriggerView in Greptile

[High impact] The PR appears safe to merge with the repository settings described by the author.

Reviews (1) · Last reviewed commit: "build(release): publish stable releases ..." · Reviewed by Greptile

Match the release flow now on rdme main. The tags job runs when the
version tag, floating major tag, or GitHub release is still missing,
even if npm already has the version. It stays on the workflow commit
and tags the commit that introduced the version. Release jobs use Node 24.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.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