Skip to content

Support pnpm workspaces (monorepos) - #4

Merged
firefoxic merged 1 commit into
mainfrom
monorepo
Aug 30, 2026
Merged

firefoxic merged 1 commit into
mainfrom
monorepo

Conversation

@firefoxic

Copy link
Copy Markdown
Owner

Closes #3.

What

Teaches release-it.sh to release pnpm workspaces. Detection is automatic: when pnpm-workspace.yaml lists packages, the release candidates are the non-private workspace packages — never the root — and a plain repository remains the degenerate case of a single candidate living in ..

  • The changelog stays the input. Each package keeps its own CHANGELOG.md; a non-empty [Unreleased] section selects the package for the release and its headings pick that package's bump, so versions stay independent. An empty section means the package sits this release out (a workspace where nothing has changes is an error, as is an empty section in a single-package repo).
  • Tags are <name>@<version> (widget@1.3.0, @acme/widget@1.3.0) — a bare v1.3.0 could not say which package it names. The [Unreleased] compare link in a package changelog points at that tag, and the rewriter now parses the link by its /compare/<tag-prefix> marker instead of a hard-coded v.
  • One commit for the whole release, carrying every bumped package.json and every rewritten CHANGELOG.md, one tag per package; then one pnpm publish (via pnpm -C <dir>) and one gh release create per package, notes taken from that package's changelog. Branch semantics (release, release-<name>, release-, release-first-major and its prereleases) apply to every released package; authentication and the final rebase of main still happen once. --dry-run previews all of it per package.

How the pipeline changed

pnpm version no longer makes the commit: every manifest is bumped with --no-git-tag-version, all changelogs are rendered to temp files first, and only when every one of them rendered does the script commit, tag and push. Fallout, both fixes in their own right:

  • A changelog that cannot be rewritten now takes the version bumps back and leaves the tree clean — previously it left a version commit and a tag behind — and the delete-tag/amend/retag dance is gone.
  • A dirty working tree is refused up front with a clear message, since the release commit adds its files by name; previously pnpm version refused it later and less clearly.
  • The [Unreleased] extractor now stops at link definitions, so a changelog with no releases yet (where [Unreleased] is followed directly by its own compare link) reads as empty instead of as notes consisting of that link.

Tests

A workspace fixture (make_workspace / add_package / finish_workspace) plus 18 new tests in tests/monorepo.test.sh cover selection, per-package bumps, scoped names, tag naming, changelog links, publishes, GitHub releases, prerelease and first-major branches, the failure paths and --dry-run. The pnpm stub now understands -C <dir> and the gh stub accumulates notes across calls. 91 passed, 0 failed, and a manual --dry-run smoke test in a real two-package workspace walks the whole pipeline correctly.

A repository whose pnpm-workspace.yaml lists packages is now a monorepo:
every non-private package with entries under [Unreleased] in its own
CHANGELOG.md is released — with its own bump, a <name>@<version> tag, its
own npm publish and GitHub release — all in one commit. Packages with an
empty [Unreleased] section sit the release out, and the root never takes
part. A plain repository stays the degenerate case of one package in '.'.

The version is no longer committed by pnpm version: every manifest is
bumped with --no-git-tag-version, the changelogs are all rendered first,
and only then does the script commit and tag — so a changelog that cannot
be rewritten takes the bumps back instead of leaving a version commit and
a tag behind, and the old delete-tag/amend/retag dance is gone. That also
means the script now refuses a dirty working tree up front, since the
release commit adds its files by name.

The [Unreleased] section extractor now stops at link definitions, so a
changelog with no releases yet is read as empty rather than as notes
consisting of its own compare link.

Closes #3
@firefoxic firefoxic self-assigned this Aug 30, 2026
@firefoxic
firefoxic merged commit 7105f15 into main Aug 30, 2026
2 checks passed
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.

Support pnpm workspaces (monorepos)

1 participant