pre-release
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesepre-release — Release Readiness & Changeset Generation
预发布 — 发布就绪检查与变更集生成
A structured pre-release workflow that runs automated checks, generates user-facing
changesets from git history, and optionally spawns fresh-eyes README reviewers.
这是一个结构化的预发布工作流,可运行自动化检查、从Git历史生成面向用户的变更集,还可选择性地发起全新视角的README审查。
When to Use
适用场景
- Before any or version bump
npm publish - When you need to generate CHANGELOG entries from recent work
- Before merging a release PR
- Any time you want a release-readiness report
- 在执行任何或版本升级之前
npm publish - 当你需要从近期工作中生成CHANGELOG条目时
- 在合并发布PR之前
- 任何需要获取发布就绪报告的时刻
Prerequisites
前置条件
The target project must have initialized:
@changesets/clibash
npm install --save-dev @changesets/cli @changesets/changelog-github
npx changeset initSee Changesets Setup for first-time configuration.
目标项目必须已初始化:
@changesets/clibash
npm install --save-dev @changesets/cli @changesets/changelog-github
npx changeset init首次配置请查看Changesets 配置。
The Workflow
工作流
Step 1: Pre-Flight Checks
步骤1:预发布预检
Run these checks against the project root. Report each as ✅ / ❌ / ⚠️:
| # | Check | How |
|---|---|---|
| 1 | README.md exists with: purpose, install, usage, prerequisites, license | Read and verify sections |
| 2 | LICENSE file present and matches | Compare files |
| 3 | No hardcoded credentials, API keys, or personal paths in tracked files | |
| 4 | No TODO/FIXME/HACK in shipped code | |
| 5 | Tests pass | |
| 6 | Lint passes | |
| 7 | Build succeeds | |
| 8 | Git working tree clean | |
| 9 | On correct branch | |
| 10 | .gitignore covers: | Read |
| 11 | | Read and verify |
| 12 | | Read and verify |
| 13 | GitHub Actions release workflow uses Trusted Publishers (OIDC), not | Read |
| 14 | Trusted Publisher configured on npmjs.com for this package | Ask user to confirm (cannot be checked programmatically) |
| 15 | History scan clean (gitleaks + trufflehog) | |
| 16 | Workflow security audit | Read all |
| 17 | Template-only values in examples | |
| 18 | No | |
| 19 | Redaction review for docs & screenshots | Scan README, docs/, and any images for: internal domains ( |
| 20 | Skills discovery (if project ships skills) | Only if |
Blockers (must fix before release): checks 1-5, 8, 11-18, 20 (if applicable).
Warnings (should fix): checks 6-7, 9-10, 19.
Info: anything else notable.
针对项目根目录运行以下检查,每项结果标记为✅ / ❌ / ⚠️:
| 序号 | 检查项 | 检查方式 |
|---|---|---|
| 1 | README.md包含:用途、安装、使用方法、前置条件、许可证 | 读取并验证各章节 |
| 2 | 存在LICENSE文件且与 | 对比文件内容 |
| 3 | 已跟踪文件中无硬编码凭证、API密钥或个人路径 | |
| 4 | 发布代码中无TODO/FIXME/HACK标记 | |
| 5 | 测试通过 | |
| 6 | 代码检查通过 | |
| 7 | 构建成功 | |
| 8 | Git工作区干净 | |
| 9 | 当前处于正确分支 | |
| 10 | .gitignore已覆盖: | 读取 |
| 11 | | 读取并验证 |
| 12 | | 读取并验证 |
| 13 | GitHub Actions发布工作流使用可信发布者(OIDC),而非 | 读取 |
| 14 | npmjs.com上已为该包配置可信发布者 | 请用户确认(无法通过编程方式检查) |
| 15 | 历史记录扫描干净(gitleaks + trufflehog) | |
| 16 | 工作流安全审计 | 读取所有 |
| 17 | 示例中仅使用模板值 | |
| 18 | 无 | |
| 19 | 文档与截图的脱敏审查 | 扫描README、docs/及所有图片,检查是否包含:内部域名( |
| 20 | 技能发现(若项目发布技能) | 仅当存在 |
阻塞项(发布前必须修复):检查项1-5、8、11-18、20(若适用)。
警告项(建议修复):检查项6-7、9-10、19。
信息项:其他值得注意的内容。
Step 2: Generate Changesets
步骤2:生成变更集
This is the core value — AI-written, user-facing release notes instead of mechanical commit scraping.
这是核心价值所在 —— 由AI编写的、面向用户的发布说明,而非机械的提交记录抓取。
2a. Find the range
2a. 确定范围
bash
undefinedbash
undefinedLast release tag
上一个发布标签
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
If no tags, use first commit
若无标签,使用首次提交
if [ -z "$LAST_TAG" ]; then
RANGE="$(git rev-list --max-parents=0 HEAD)..HEAD"
echo "No previous tags found — covering entire history"
else
RANGE="${LAST_TAG}..HEAD"
echo "Changes since $LAST_TAG"
fi
undefinedif [ -z "$LAST_TAG" ]; then
RANGE="$(git rev-list --max-parents=0 HEAD)..HEAD"
echo "未找到之前的标签 —— 覆盖全部历史"
else
RANGE="${LAST_TAG}..HEAD"
echo "自$LAST_TAG以来的变更"
fi
undefined2b. Gather the raw material
2b. 收集原始素材
bash
undefinedbash
undefinedCommits with files changed
包含文件变更的提交
git log $RANGE --pretty=format:'%h %s' --no-merges
git log $RANGE --pretty=format:'%h %s' --no-merges
For more context on what changed
查看变更的更多上下文
git log $RANGE --pretty=format:'### %h %s%n%b' --no-merges
git log $RANGE --pretty=format:'### %h %s%n%b' --no-merges
Files changed (to understand scope)
变更的文件(了解范围)
git diff --stat $LAST_TAG..HEAD 2>/dev/null || git diff --stat $(git rev-list --max-parents=0 HEAD)..HEAD
Also check for **existing pending changesets** — don't duplicate:
```bash
ls .changeset/*.md 2>/dev/null | grep -v README.mdIf there are already changeset files, read them and account for what's already covered.
git diff --stat $LAST_TAG..HEAD 2>/dev/null || git diff --stat $(git rev-list --max-parents=0 HEAD)..HEAD
同时检查**已存在的待处理变更集** —— 避免重复:
```bash
ls .changeset/*.md 2>/dev/null | grep -v README.md若已存在变更集文件,请读取并确认已覆盖的内容。
2c. Classify and write changesets
2c. 分类并编写变更集
Group commits by impact and write changeset files. Each changeset is a markdown file in :
.changeset/File format ():
.changeset/<descriptive-name>.mdmarkdown
---
"package-name": patch
---
Brief, user-facing description of what changed.Semver classification:
| Type | Bump | Examples |
|---|---|---|
| Breaking API changes | | Removed function, changed signature, dropped Node version |
| New features, capabilities | | New command, new option, new API |
| Bug fixes, docs, internal | | Fix crash, update README, refactor internals |
Writing guidelines:
- Write for users, not developers. "Added flag" not "refactored logger module"
--verbose - Group related commits into a single changeset when they're part of one logical change
- Use present tense: "Add", "Fix", "Remove", not "Added", "Fixed", "Removed"
- If a commit is purely internal (CI, refactor with no behavior change), it can be omitted or grouped under a generic "Internal improvements" patch
- One changeset per logical change, not per commit
Name the files descriptively using kebab-case: , , .
add-verbose-flag.mdfix-auth-crash.mdinitial-release.md按影响程度分组提交,并编写变更集文件。每个变更集是目录下的一个markdown文件:
.changeset/文件格式():
.changeset/<描述性名称>.mdmarkdown
---
"package-name": patch
---
简短的、面向用户的变更描述。语义化版本分类:
| 类型 | 版本升级幅度 | 示例 |
|---|---|---|
| 破坏性API变更 | | 移除函数、修改签名、放弃对旧Node版本的支持 |
| 新功能、新能力 | | 新增命令、新增选项、新增API |
| Bug修复、文档更新、内部优化 | | 修复崩溃、更新README、内部重构 |
编写指南:
- 为用户编写,而非开发者。例如写“新增标志”而非“重构日志模块”
--verbose - 当多个提交属于同一逻辑变更时,将它们分组到一个变更集中
- 使用现在时态:“Add”、“Fix”、“Remove”,而非“Added”、“Fixed”、“Removed”
- 若提交纯为内部变更(CI、无行为变化的重构),可省略或归类到通用的“内部改进”patch变更集中
- 每个逻辑变更对应一个变更集,而非每个提交对应一个
使用短横线命名法为文件命名:、、。
add-verbose-flag.mdfix-auth-crash.mdinitial-release.md2d. For initial releases (no previous tags)
2d. 首次发布(无之前的标签)
Write a single changeset covering the initial release:
markdown
---
"package-name": minor
---
Initial release.
- Feature 1: brief description
- Feature 2: brief description
- Feature 3: brief descriptionUse (0.1.0) for initial releases unless the project is already at 1.x.
minor编写一个覆盖首次发布的变更集:
markdown
---
"package-name": minor
---
首次发布。
- 功能1:简要描述
- 功能2:简要描述
- 功能3:简要描述首次发布使用版本(0.1.0),除非项目已处于1.x版本。
minorStep 3: Fresh-Eyes README Review (Optional)
步骤3:全新视角的README审查(可选)
Load the skill. Use pi-subagents to spawn 2 parallel agents on different models to review the README as first-time users:
run-agentsjson
{ "tasks": [
{ "agent": "_arch-reviewer", "task": "Read the README.md in <project-path>. You are a developer who has NEVER seen this project. Can you answer: (1) What does it do? (2) How to install? (3) How to use? (4) Prerequisites? (5) Where to get help? For each: quote relevant text or say MISSING. Then list anything confusing or that assumes prior knowledge.", "model": "google/gemini-3-pro" },
{ "agent": "_arch-reviewer", "task": "Read the README.md in <project-path>. You are a developer who has NEVER seen this project. Can you answer: (1) What does it do? (2) How to install? (3) How to use? (4) Prerequisites? (5) Where to get help? For each: quote relevant text or say MISSING. Then list anything confusing or that assumes prior knowledge.", "model": "github-copilot/gpt-5.3" }
]}Read both outputs and note any gaps.
加载技能。使用pi-subagents并行启动2个不同模型的代理,以首次接触项目的用户身份审查README:
run-agentsjson
{ "tasks": [
{ "agent": "_arch-reviewer", "task": "Read the README.md in <project-path>. You are a developer who has NEVER seen this project. Can you answer: (1) What does it do? (2) How to install? (3) How to use? (4) Prerequisites? (5) Where to get help? For each: quote relevant text or say MISSING. Then list anything confusing or that assumes prior knowledge.", "model": "google/gemini-3-pro" },
{ "agent": "_arch-reviewer", "task": "Read the README.md in <project-path>. You are a developer who has NEVER seen this project. Can you answer: (1) What does it do? (2) How to install? (3) How to use? (4) Prerequisites? (5) Where to get help? For each: quote relevant text or say MISSING. Then list anything confusing or that assumes prior knowledge.", "model": "github-copilot/gpt-5.3" }
]}读取两个输出并记录任何遗漏点。
Step 4: Report
步骤4:生成报告
Present the final report in this structure:
markdown
undefined按照以下结构呈现最终报告:
markdown
undefinedPre-Release Report: <package-name>
预发布报告:<package-name>
Version: <current> → <proposed>
版本:<当前版本> → <提议版本>
Date: <today>
日期:<今日日期>
Checklist
检查清单
| # | Check | Status | Notes |
|---|---|---|---|
| 1 | README | ✅/❌ | ... |
| ... |
| 序号 | 检查项 | 状态 | 备注 |
|---|---|---|---|
| 1 | README | ✅/❌ | ... |
| ... |
Changesets Generated
生成的变更集
| File | Bump | Summary |
|---|---|---|
| minor | Add feature X |
| ... |
| 文件 | 版本升级幅度 | 摘要 |
|---|---|---|
| minor | 新增功能X |
| ... |
README Review
README审查
(If Step 3 was run)
- Gaps: ...
- Confusing: ...
(若执行了步骤3)
- 遗漏点:...
- 易混淆点:...
Blockers (must fix)
阻塞项(必须修复)
- ...
- ...
Suggestions (can wait)
建议项(可延后)
- ...
- ...
Ready to Release?
是否准备好发布?
YES / NO — N blockers remain
undefined是 / 否 —— 仍有N个阻塞项
undefinedStep 5: Commit (if approved)
步骤5:提交(若获得批准)
If the user approves, commit the changeset files:
bash
git add .changeset/*.md
git commit -m "chore: add changesets for next release" -m "Co-Authored-By: Pi <noreply@pi.dev>"若用户批准,提交变更集文件:
bash
git add .changeset/*.md
git commit -m "chore: add changesets for next release" -m "Co-Authored-By: Pi <noreply@pi.dev>"Changesets Setup
Changesets配置
For projects that don't have changesets yet. Run once:
针对尚未配置changesets的项目,仅需运行一次:
1. Install
1. 安装
bash
npm install --save-dev @changesets/cli @changesets/changelog-github
npx changeset initbash
npm install --save-dev @changesets/cli @changesets/changelog-github
npx changeset init2. Configure .changeset/config.json
.changeset/config.json2. 配置.changeset/config.json
.changeset/config.jsonjson
{
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
"changelog": "@changesets/changelog-github",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}Set for scoped packages ().
Set to your default branch.
"access": "public"@scope/name"baseBranch"json
{
"$schema": "https://unpkg.com/@changesets/config@3.1.2/schema.json",
"changelog": "@changesets/changelog-github",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}对于作用域包(),设置。
将设置为你的默认分支。
@scope/name"access": "public""baseBranch"3. Add npm scripts to package.json
package.json3. 向package.json
添加npm脚本
package.jsonjson
{
"scripts": {
"changeset": "changeset",
"version-packages": "changeset version",
"release": "changeset publish"
}
}json
{
"scripts": {
"changeset": "changeset",
"version-packages": "changeset version",
"release": "changeset publish"
}
}4. GitHub Actions workflow (.github/workflows/release.yml
)
.github/workflows/release.yml4. GitHub Actions工作流(.github/workflows/release.yml
)
.github/workflows/release.ymlyaml
name: Release
on:
push:
branches: [main]
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write # Required for npm Trusted Publishing (OIDC)
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24 # npm >= 11.5.1 required for Trusted Publishing
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm test
- name: Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset publish
title: "chore: version packages"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}yaml
name: Release
on:
push:
branches: [main]
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
contents: write
pull-requests: write
id-token: write # 用于npm可信发布(OIDC)的必填项
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24 # npm >= 11.5.1 是可信发布的要求
cache: npm
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm run build
- run: npm test
- name: Create Release PR or Publish
id: changesets
uses: changesets/action@v1
with:
publish: npx changeset publish
title: "chore: version packages"
commit: "chore: version packages"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}5. Configure Trusted Publishing (recommended — no tokens needed)
5. 配置可信发布(推荐 —— 无需令牌)
npm's Trusted Publishing uses OIDC to authenticate
GitHub Actions with the npm registry. No secret required.
NPM_TOKEN- Go to your package on npmjs.com → Settings → Trusted Publisher
- Select GitHub Actions and configure:
- Organization or user: your GitHub username
- Repository: your repo name
- Workflow filename:
release.yml
- That's it. The permission in the workflow enables OIDC. Provenance attestations are generated automatically.
id-token: write
After verifying Trusted Publishing works, go to package Settings → Publishing access →
"Require two-factor authentication and disallow tokens" for maximum security.
⚠️ NPM_TOKEN is deprecated: Do not use secrets for publishing from
GitHub Actions. Trusted Publishers (OIDC) is the only supported method. If you encounter
an existing workflow using , migrate it to Trusted Publishers. See:
https://docs.npmjs.com/trusted-publishers
NPM_TOKENNPM_TOKENnpm的可信发布使用OIDC验证GitHub Actions与npm注册表的身份,无需密钥。
NPM_TOKEN- 访问npmjs.com上你的包 → 设置 → 可信发布者
- 选择GitHub Actions并配置:
- 组织或用户:你的GitHub用户名
- 仓库:你的仓库名称
- 工作流文件名:
release.yml
- 完成配置。工作流中的权限启用了OIDC,溯源证明会自动生成。
id-token: write
验证可信发布正常工作后,进入包设置 → 发布权限 →
**"要求双因素认证并禁用令牌"**以获得最高安全性。
⚠️ NPM_TOKEN已弃用:请勿在GitHub Actions的发布工作流中使用密钥。可信发布者(OIDC)是唯一受支持的方式。若遇到使用的现有工作流,请将其迁移到可信发布者。参考:
https://docs.npmjs.com/trusted-publishers
NPM_TOKENNPM_TOKENTips
小贴士
- Run this skill early and often, not just before release. The checklist catches issues faster when run during development.
- Edit generated changesets freely. They're just markdown files — tweak wording, merge entries, split large ones.
- One changeset per PR is a good rhythm. The pre-release skill can also be run to generate changesets for a single PR's worth of work.
- For monorepos, changesets handles multi-package versioning natively. List multiple packages in the frontmatter.
- 尽早且频繁地运行此技能,不要只在发布前才用。在开发过程中运行检查清单能更快发现问题。
- 自由编辑生成的变更集。它们只是markdown文件 —— 调整措辞、合并条目、拆分大条目均可。
- 每个PR对应一个变更集是良好的节奏。预发布技能也可用于为单个PR的工作生成变更集。
- 对于单仓库多包项目,changesets原生支持多包版本管理。在前置内容中列出多个包即可。