changesets
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChangesets
Changesets
Overview
概述
Changesets is a versioning and changelog management tool focused on multi-package repositories. Contributors declare the semver impact of each change (major/minor/patch) via changeset files, then Changesets aggregates them to bump versions, update changelogs, and publish packages in a single coordinated release.
When to use: Monorepo versioning, automated changelog generation, coordinated multi-package releases, CI-driven publishing, prerelease/snapshot workflows.
When NOT to use: Single-file projects with no npm publishing, projects using commit-message-based versioning (semantic-release), manual version management without an npm registry, projects where a single maintainer controls all releases without PR collaboration.
Changesets是一款专注于多包仓库的版本管理与变更日志管理工具。贡献者通过changeset文件声明每个变更的semver影响(主版本/次版本/修订版本),随后Changesets会汇总这些信息,统一完成版本号升级、变更日志更新以及包发布工作。
适用场景: Monorepo版本管理、自动化变更日志生成、多包协同发布、CI驱动的包发布、预发布/快照版本流程。
不适用场景: 无需发布到npm的单文件项目、基于提交信息进行版本管理的项目(如semantic-release)、不依赖npm注册表的手动版本管理项目、由单一维护者全权控制发布且无需PR协作的项目。
How It Works
工作原理
- A contributor adds a changeset file declaring affected packages, bump types, and a summary
- The changeset file is committed alongside the code change in the PR
- When ready to release, consumes all pending changesets and updates versions and changelogs
changeset version - publishes the updated packages to npm and creates git tags
changeset publish - In CI, the official GitHub Action automates steps 3-4 via an auto-maintained "Version Packages" PR
- 贡献者添加一个changeset文件,声明受影响的包、版本升级类型以及变更摘要
- 该changeset文件与代码变更一起提交到PR中
- 准备发布时,执行命令,处理所有待处理的changeset,更新版本号和变更日志
changeset version - 执行命令,将更新后的包发布到npm并创建git标签
changeset publish - 在CI环境中,官方GitHub Action会通过自动维护的“Version Packages”PR自动完成步骤3-4
Key Concepts
核心概念
- Changeset file — A markdown file in declaring which packages are affected, their bump type (major/minor/patch), and a human-readable summary that appears in the changelog
.changeset/ - Version command — Consumes all pending changeset files, calculates final version bumps, updates versions, generates
package.jsonentries, and bumps internal dependency rangesCHANGELOG.md - Publish command — Publishes updated packages to npm and creates git tags; must run immediately after with no commits in between
version - Linked packages — Packages that share the highest bump type within a release but maintain independent version numbers
- Fixed packages — Packages that always share the exact same version number across the group
- Prerelease mode — A mode where produces prerelease versions (e.g.,
version) for testing before stable release1.0.0-beta.0 - Snapshot releases — Temporary versions for ad-hoc testing without affecting the main release line
0.0.0-timestamp
- Changeset文件 — 位于目录下的Markdown文件,声明受影响的包、版本升级类型(主版本/次版本/修订版本),以及会显示在变更日志中的人类可读摘要
.changeset/ - Version命令 — 处理所有待处理的changeset文件,计算最终版本升级幅度,更新中的版本号,生成
package.json条目,并升级内部依赖的版本范围CHANGELOG.md - Publish命令 — 将更新后的包发布到npm并创建git标签;必须在命令执行后立即运行,中间不能有其他提交
version - 关联包(Linked packages) — 在一次发布中共享最高版本升级类型,但保持独立版本号的包组
- 固定版本包(Fixed packages) — 始终共享完全相同版本号的包组
- 预发布模式 — 一种特殊模式,执行命令会生成预发布版本(如
version),用于稳定版发布前的测试1.0.0-beta.0 - 快照版本 — 临时的版本,用于临时测试,不会影响正式发布线
0.0.0-timestamp
Configuration Quick Reference
配置速查
| Option | Default | Description |
|---|---|---|
| | Changelog generator package or |
| | Auto-commit on |
| | npm publish access; set |
| | Branch used for change detection |
| | Groups of packages that share highest bump type |
| | Groups of packages that share exact version |
| | Packages excluded from changeset versioning |
| | When to bump dependents: |
| | Version/tag behavior for |
| 选项 | 默认值 | 说明 |
|---|---|---|
| | 变更日志生成器包,设置为 |
| | 在 |
| | npm发布权限;对于公开的作用域包,需设置为 |
| | 用于检测变更的基准分支 |
| | 共享最高版本升级类型的包组 |
| | 共享完全相同版本号的包组 |
| | 排除在Changesets版本管理之外的包 |
| | 何时升级内部依赖的版本: |
| | 标记为 |
Quick Reference
命令速查
| Pattern | Command / Config | Key Points |
|---|---|---|
| Initialize | | Creates |
| Add changeset | | Interactive prompt for packages and bump type |
| Add empty changeset | | Declares no packages need versioning (satisfies CI) |
| Version packages | | Consumes changesets, bumps versions, updates changelogs |
| Publish packages | | Publishes to npm, creates git tags |
| Check status | | Lists pending changesets; exits 1 if changes lack changesets |
| Status since branch | | Only checks changes since diverging from main |
| Enter prerelease | | Enables prerelease mode (beta, alpha, rc, next) |
| Exit prerelease | | Returns to normal versioning mode |
| Snapshot version | | Creates 0.0.0-timestamp versions for testing |
| Snapshot publish | | Publishes snapshot without overwriting latest dist-tag |
| Link packages | | Packages share the highest version bump type |
| Fix packages | | Packages share the exact same version number |
| Ignore packages | | Excludes packages from changeset versioning |
| Public access | | Required for publishing public scoped packages |
| GitHub changelog | | Adds PR links and contributor attribution |
| Auto-commit | | Version and add commands auto-commit changes |
| Internal deps | | Controls when internal dependents get bumped |
| 场景 | 命令 / 配置 | 关键要点 |
|---|---|---|
| 初始化 | | 创建包含配置文件的 |
| 添加changeset | | 交互式提示选择受影响的包和版本升级类型 |
| 添加空changeset | | 声明无包需要升级版本(用于满足CI检查) |
| 升级包版本 | | 处理所有待处理的changeset,升级版本号并更新变更日志 |
| 发布包 | | 发布到npm并创建git标签 |
| 检查状态 | | 列出所有待处理的changeset;如果变更未添加changeset则返回状态码1 |
| 检查分支差异状态 | | 仅检查与main分支分叉后的变更 |
| 进入预发布模式 | | 启用预发布模式(如beta、alpha、rc、next) |
| 退出预发布模式 | | 恢复到正常版本管理模式 |
| 生成快照版本 | | 创建 |
| 发布快照版本 | | 发布快照版本,且不会覆盖 |
| 关联包 | | 包组共享最高版本升级幅度 |
| 固定包版本 | | 包组共享完全相同的版本号 |
| 忽略包 | | 将包排除在Changesets版本管理之外 |
| 公开访问权限 | | 发布公开npm包时必须设置 |
| GitHub风格变更日志 | | 添加PR链接和贡献者信息 |
| 自动提交 | | version和add命令执行后自动提交变更 |
| 内部依赖升级 | | 控制何时升级内部依赖的版本 |
Common Mistakes
常见错误
| Mistake | Correct Pattern |
|---|---|
Committing between | Run |
Forgetting | Use |
Using | Use |
Setting | Set |
Not including | Full git history is needed for changeset detection |
Running | Always run build step before |
| Entering prerelease mode on main branch | Use a dedicated branch for prereleases to avoid blocking normal releases |
| Ignoring packages that others depend on | Ignored packages skip bumps, breaking dependents — use sparingly |
| Publishing snapshots with default tag | Always use |
Not setting | Both |
Using | The official |
Manually editing generated | Edit changeset files instead; changelogs are regenerated on |
| 错误操作 | 正确做法 |
|---|---|
在 | 执行 |
| 无包变更的PR未添加空changeset | 使用 |
当包需要共享完全相同版本时使用 | 包版本完全相同时使用 |
公开包设置 | 公开npm包需在配置中设置 |
CI检出时未设置 | Changeset检测需要完整的git历史 |
未构建就执行 | 执行 |
| 在主分支进入预发布模式 | 使用专门的分支进行预发布,避免阻塞正常版本发布 |
| 忽略被其他包依赖的包 | 被忽略的包不会升级版本,会导致依赖它的包出现问题——需谨慎使用 |
| 使用默认标签发布快照版本 | 发布快照版本时必须使用 |
CI环境中未设置 | 自动发布需要同时配置 |
CI中直接使用 | 官方 |
手动编辑自动生成的 | 如需修改变更日志,请编辑changeset文件; |
Delegation
任务委托
- CI pipeline debugging: Use agent for repository-specific workflow discovery
Explore - npm publishing issues: Use agent for debugging publish and registry authentication failures
Task
If theskill is available, delegate build orchestration, task caching, and CI optimization to it. If theturboreposkill is available, delegate workspace setup, dependency linking, catalogs, and Docker deployment to it. See its monorepo integration reference for the end-to-end release pipeline.pnpm-workspace
- CI流水线调试:使用Explore Agent进行仓库特定的工作流排查
- npm发布问题:使用Task Agent调试发布和注册表认证失败问题
如果技能可用,将构建编排、任务缓存和CI优化工作委托给它。 如果turborepo技能可用,将工作区设置、依赖关联、目录管理和Docker部署工作委托给它。请参考其Monorepo集成文档获取端到端的发布流程说明。pnpm-workspace
References
参考资料
- Basic workflow: adding changesets, versioning, publishing, CI integration
- Monorepo setup: configuration, linked packages, fixed versioning, ignore patterns
- CI automation: GitHub Actions, automated PRs, snapshot releases, prerelease channels
- 基础工作流:添加changeset、版本升级、发布、CI集成
- Monorepo配置:配置项、关联包、固定版本、忽略规则
- CI自动化:GitHub Actions、自动PR、快照发布、预发布通道