Talk Notes: Releasing Many Packages From One Repository
A monorepo makes it easy to change five packages in one pull request. It also makes it easy to release five packages in the wrong order, with the wrong versions, pointing at each other with ranges that no longer exist on the registry. These are notes from a talk on getting monorepo releases under control. They are written up in full; there is no video or event to attend.
Agenda
- Two versioning models, and how to choose
- Internal dependency ranges and the workspace protocol
- Publishing in dependency order
- Changelogs per package
- Notes for Go and Rust workspaces
- Audience questions
Choosing a versioning model
| Fixed (lockstep) | Independent | |
|---|---|---|
| How it works | Every package shares one version number | Each package bumps on its own changes |
| Strength | Users know which versions go together | No meaningless bumps for untouched packages |
| Weakness | A fix in one package bumps all of them | Users need a compatibility table |
| Fits | Tightly coupled families such as a framework and its official plugins | Loosely related utilities sharing tooling |
The point made in the talk: choose consciously and write it in the contributing guide. Mixed, accidental policies are the real problem.
Internal dependency ranges
Inside the repo, package P depends on package Q. You want local development to use the working copy of Q, but the published P must depend on a real published Q version. pnpm and Yarn support a workspace: protocol for this, and replace it with a concrete range when packing:
// packages/p/package.json (in the repo)
"dependencies": {
"@example-org/q": "workspace:^"
}
// what the published tarball contains
"dependencies": {
"@example-org/q": "^2.4.0"
}
npm workspaces link local packages too, but you write normal ranges and must keep them current yourself. Whichever manager you use, inspect a packed tarball at least once to see what consumers will receive.
Publishing in order
- Compute the internal dependency graph.
- Publish dependencies before dependents: packages that others in the batch rely on go first, and packages nothing else depends on go last.
- If a publish fails midway, stop. Re-running should skip versions that already exist rather than failing the whole batch.
Release tools built for monorepos, Changesets being a widely used example in JavaScript, do the graph sorting and the version bumping for you. Their main contribution is forcing each pull request to state which packages it affects and how.
Changelogs per package
A single root changelog quickly becomes useless to someone who only installs one package. Keep a CHANGELOG.md in each package directory, generated from the same change notes. When a package is bumped only because a dependency changed, say so in one line, so readers do not hunt for a change that is not there.
Notes for Go and Rust
- Go: a repository can hold several modules. Each module's tags are prefixed with its directory, so
storage/v1.3.0releases the module instorage/. The Go Modules Reference describes this. - Rust: a Cargo workspace shares a lockfile and target directory, but each crate is published separately to crates.io, and dependents must be published after the crates they depend on.
Audience questions
Can we release only what changed?
Yes, with independent versioning. Make sure "changed" includes changes to shared build config that alter the output.
Should private internal packages live in the same workspace?
That is fine; mark them "private": true so a publish command can never send them to a registry.
How do we preview a release?
Many teams publish snapshot versions to a pre-release tag such as next from the release branch. Users opt in with npm install pkg@next, and the latest tag is untouched.
If your packages are scoped, the scoped packages session notes cover access and registry setup, and the release pipeline diagrams show where these steps sit.