release-please
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineserelease-please
release-please
Overview
概述
release-please automates versioning and releases by analyzing Conventional Commit messages:
- Push conventional commits to your default branch
- release-please creates/updates a Release PR with version bump and changelog
- Merge the Release PR to trigger a GitHub Release
- Publish step runs when a release is created (npm, PyPI, crates.io, etc.)
release-please handles version determination, changelog generation, and git tagging. You write good commit messages; it does the rest.
release-please通过分析Conventional Commit提交信息,实现版本管理和发布流程自动化:
- 推送符合Conventional Commits规范的提交到默认分支
- release-please会创建/更新发布PR,包含版本升级和变更日志内容
- 合并发布PR即可触发GitHub Release生成
- 发布步骤会在Release创建时自动执行(支持npm、PyPI、crates.io等平台)
release-please会自动处理版本判定、变更日志生成和git打标签操作,你只需要编写规范的提交信息,其余工作都由它完成。
Commit Message Assistance
提交信息协助
When a user asks for help writing a commit message (not setting up a pipeline):
- Ask what changed — "What did you change and why?" (skip if already described)
- Suggest the type — Pick from the type table below, explain why that type fits
- Draft the message — Write the full commit message (header + body if needed + footers)
- Confirm — Present it for the user to approve or adjust
If the change is breaking, always include a footer explaining migration impact.
BREAKING CHANGE:当用户需要协助编写提交信息(而非设置流水线)时:
- 询问变更内容——「你修改了什么内容,修改原因是什么?」(如果用户已经说明可跳过本步)
- 建议提交类型——从下表中选择合适的类型,解释选择该类型的原因
- 草拟提交信息——编写完整的提交信息(标题+可选正文+可选页脚)
- 确认内容——将草拟的内容提交给用户确认或调整
如果变更属于破坏性更新,必须添加页脚说明迁移影响。
BREAKING CHANGE:Pipeline Setup Flow
流水线设置流程
When a user wants to set up release-please, follow this interactive protocol.
If (or similar) already exists, read it first, compare against the templates in , and suggest specific improvements rather than replacing it wholesale. Common improvement opportunities: missing concurrency groups, publish not gated on , missing idempotent publish check, overly broad permissions.
.github/workflows/release.ymlreferences/workflow-templates.mdrelease_created当用户需要设置release-please时,遵循以下交互流程。
如果仓库中已存在(或类似文件),请先读取该文件,与中的模板对比,建议针对性的优化点而非直接完全替换。常见的优化点包括:缺失并发组配置、发布步骤未通过条件控制、缺失幂等发布校验、权限范围过大。
.github/workflows/release.ymlreferences/workflow-templates.mdrelease_createdStep 1: Detect Project Type
步骤1:检测项目类型
Scan the repository for package manifests:
| File | Release Type |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
If multiple manifests exist at the root, ask which is primary. If none found, use .
simple扫描仓库中的包配置文件判定项目类型:
| 文件 | 发布类型 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
如果根目录下存在多个配置文件,询问用户哪个是主配置。如果未检测到任何配置文件,使用类型。
simpleStep 2: Ask Configuration Questions
步骤2:询问配置相关问题
Ask these questions (skip any already answered or obvious from context):
- Is this a monorepo? (multiple packages in subdirectories)
- What is the default branch? (default: )
main - Do you need pre-release support? (manual alpha/beta/rc releases)
- Where do you publish? (npm, GitHub Packages, PyPI, Maven Central, crates.io, Docker, none)
- What is the current version? (check package manifest, default: )
0.0.0
询问以下问题(如果用户已经回答或可从上下文推断可跳过):
- 这是一个monorepo吗?(子目录下存在多个包)
- 默认分支名称是什么?(默认值:)
main - 需要预发布支持吗?(手动的alpha/beta/rc版本发布)
- 你需要发布到哪些平台?(npm、GitHub Packages、PyPI、Maven Central、crates.io、Docker、无需发布)
- 当前版本号是多少?(从包配置文件中读取,默认值:)
0.0.0
Step 3: Generate Files
步骤3:生成配置文件
Create three files based on the answers:
根据上述回答生成三个文件:
release-please-config.json
release-please-config.json
json
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
".": {
"release-type": "node",
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"versioning": "default",
"extra-files": []
}
}
}Adjust based on detected project type. For monorepos, add multiple entries under with names.
release-typepackagescomponentjson
{
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
"packages": {
".": {
"release-type": "node",
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"draft": false,
"prerelease": false,
"versioning": "default",
"extra-files": []
}
}
}根据检测到的项目类型调整。如果是monorepo,在下添加多个条目并配置名称。
release-typepackagescomponent.release-please-manifest.json
.release-please-manifest.json
json
{
".": "1.0.0"
}Set to the current released version. Use for new projects.
"0.0.0"json
{
".": "1.0.0"
}设置为当前已发布的版本号,新项目使用。
"0.0.0".github/workflows/release.yml
.github/workflows/release.yml
For Node.js → npm public registry (most common), use this base template:
yaml
name: Release
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: googleapis/release-please-action@v4
id: release
publish:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}For other ecosystems, see for complete templates including:
references/workflow-templates.md- Node.js → GitHub Packages (with idempotent publish check)
- Python → PyPI (trusted publishers)
- Java → Maven Central
- Go (tags only, optional GoReleaser)
- Rust → crates.io
- Docker (build + push with semver tags)
- Monorepo (per-package publish jobs)
- Pre-release pattern (workflow_dispatch with version resolution)
Always customize:
- Replace with the actual default branch if different
main - Adjust Node version, Python version, Java version, etc.
- Add registry-specific secrets configuration
- If pre-release support is needed, use the pre-release template from
references/workflow-templates.md
对于Node.js → npm公共仓库(最常见场景),使用以下基础模板:
yaml
name: Release
on:
push:
branches: [main]
permissions:
contents: write
pull-requests: write
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
version: ${{ steps.release.outputs.version }}
steps:
- uses: googleapis/release-please-action@v4
id: release
publish:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: https://registry.npmjs.org
- run: npm ci
- run: npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}对于其他技术栈,可查看获取完整模板,包括:
references/workflow-templates.md- Node.js → GitHub Packages(含幂等发布校验)
- Python → PyPI(可信发布者配置)
- Java → Maven Central
- Go(仅打标签,可选GoReleaser配置)
- Rust → crates.io
- Docker(基于semver标签构建并推送)
- Monorepo(按包拆分发布任务)
- 预发布模式(带版本解析的workflow_dispatch配置)
必须按需自定义:
- 如果默认分支不是请替换为实际分支名
main - 调整Node版本、Python版本、Java版本等配置
- 添加对应仓库的密钥配置
- 如果需要预发布支持,使用中的预发布模板
references/workflow-templates.md
Configuration Quick Reference
配置快速参考
| Option | Default | Purpose |
|---|---|---|
| — | Package ecosystem (required) |
| | Treat |
| | Where to write the changelog |
| | Tag as |
| | One PR per package (monorepo) |
| | Create release PRs as drafts |
| | Additional files with version strings to update |
| (defaults) | Customize which types appear in changelog |
| 选项 | 默认值 | 用途 |
|---|---|---|
| — | 包所属生态(必填) |
| | 版本低于1.0.0时将 |
| | 变更日志的写入路径 |
| | 标签格式为 |
| | (monorepo场景)每个包单独生成PR |
| | 将发布PR创建为草稿状态 |
| | 需要同步更新版本号的其他文件 |
| (默认值) | 自定义变更日志中展示的提交类型 |
Monorepo Quick Setup
Monorepo快速配置
json
// release-please-config.json
{
"packages": {
"packages/core": { "release-type": "node", "component": "core" },
"packages/cli": { "release-type": "node", "component": "cli" }
}
}json
// .release-please-manifest.json
{ "packages/core": "0.0.0", "packages/cli": "0.0.0" }Use component names as commit scopes:
feat(core): add streaming supportFor full configuration options, see .
references/config-options.mdjson
// release-please-config.json
{
"packages": {
"packages/core": { "release-type": "node", "component": "core" },
"packages/cli": { "release-type": "node", "component": "cli" }
}
}json
// .release-please-manifest.json
{ "packages/core": "0.0.0", "packages/cli": "0.0.0" }提交信息中使用component名称作为scope:
feat(core): add streaming support完整配置选项可查看。
references/config-options.mdCommit Message Guide
提交信息指南
release-please reads commit messages to determine version bumps and generate changelogs. Every commit to the default branch must follow Conventional Commits.
release-please通过读取提交信息判定版本升级规则并生成变更日志,所有推送到默认分支的提交都必须遵循Conventional Commits规范。
Format
格式
<type>(<scope>): <description>
[optional body]
[optional footer(s)]- Use imperative present tense: "add" not "added"
- Do not capitalize the first letter of the description
- Do not end with a period
<type>(<scope>): <description>
[可选正文]
[可选页脚]- 使用祈使句现在时:用「add」而非「added」
- 描述首字母不要大写
- 描述末尾不要加句号
Type → Version Bump
类型对应版本升级规则
| Type | Bump | Triggers Release? |
|---|---|---|
| Minor | Yes |
| Patch | Yes |
| Patch | Yes |
| — | No |
| — | No |
| — | No |
| — | No |
| — | No |
| — | No |
| — | No |
| — | No |
Breaking changes (any type with or footer) → Major bump.
!BREAKING CHANGE:| 类型 | 升级版本 | 是否触发发布? |
|---|---|---|
| 次版本 | 是 |
| 补丁版本 | 是 |
| 补丁版本 | 是 |
| — | 否 |
| — | 否 |
| — | 否 |
| — | 否 |
| — | 否 |
| — | 否 |
| — | 否 |
| — | 否 |
破坏性变更(任意类型后加或添加页脚)→ 主版本升级。
!BREAKING CHANGE:Breaking Change Examples
破坏性变更示例
feat(api)!: redesign authentication flow
BREAKING CHANGE: /auth/login now requires OAuth2 tokens instead of API keys.refactor(database): migrate from MongoDB to PostgreSQL
BREAKING CHANGE: all database connection strings must be updated.feat(api)!: redesign authentication flow
BREAKING CHANGE: /auth/login now requires OAuth2 tokens instead of API keys.refactor(database): migrate from MongoDB to PostgreSQL
BREAKING CHANGE: all database connection strings must be updated.Special Footers
特殊页脚
| Footer | Purpose |
|---|---|
| Triggers major version bump |
| Force a specific version number |
| 页脚 | 用途 |
|---|---|
| 触发主版本升级 |
| 强制指定版本号 |
Quick Examples
快速示例
feat(booking): add search by date range endpoint
fix(auth): resolve token refresh race condition
deps: upgrade @nestjs/core to v11.0.0
test(scheduler): add unit tests for cron parser
chore: update .gitignorefeat(booking): add search by date range endpoint
fix(auth): resolve token refresh race condition
deps: upgrade @nestjs/core to v11.0.0
test(scheduler): add unit tests for cron parser
chore: update .gitignoreNo AI Co-Author Trailers
禁止添加AI共同作者页脚
NEVER add trailers for AI agents in commit messages. These pollute changelogs and git history.
Co-Authored-ByFor the complete commit conventions reference with 15+ examples, scopes guide, and anti-patterns, see .
references/commit-conventions.md绝对不要在提交信息中为AI Agent添加页脚,这会污染变更日志和git历史。
Co-Authored-By完整的提交规范参考(含15+示例、scope指南和反模式)可查看。
references/commit-conventions.mdBest Practices
最佳实践
Squash Merges
压缩合并
Configure your repository to use squash merges for feature branches. This ensures each PR produces a single conventional commit, keeping the changelog clean. Set the squash commit message to use the PR title (which should be a conventional commit message).
配置仓库使用**squash merge(压缩合并)**合并功能分支,确保每个PR对应一条Conventional Commit提交,保持变更日志整洁。设置压缩合并的提交信息使用PR标题(PR标题应为符合规范的提交信息)。
Permissions
权限配置
The GitHub Action needs and at minimum. Add or for publish steps as needed. Use the principle of least privilege — grant permissions per-job, not at workflow level.
contents: writepull-requests: writepackages: writeid-token: writeGitHub Action最少需要和权限,发布步骤按需添加或权限。遵循最小权限原则——按任务授予权限,不要在工作流全局配置权限。
contents: writepull-requests: writepackages: writeid-token: writeConcurrency
并发配置
Always set for release workflows. Canceling a release mid-way can leave partial state (tags without releases, PRs in inconsistent state).
cancel-in-progress: false发布工作流始终设置,中途取消发布可能会产生部分状态(仅生成标签未生成Release、PR状态不一致)。
cancel-in-progress: falsePublish Gating
发布条件控制
Never publish in the release-please job itself. Use a separate job gated on . This separates concerns and makes retries easier.
publishrelease_created == 'true'不要在release-please任务中直接执行发布操作,使用独立的任务,通过条件控制执行,实现职责分离,也便于重试。
publishrelease_created == 'true'Idempotent Publish
幂等发布
Check if the version already exists in the registry before publishing. This prevents failures on workflow re-runs:
yaml
- name: Check if version exists
id: check
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
if npm view "${PACKAGE_NAME}@${VERSION}" version 2>/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- if: steps.check.outputs.exists == 'false'
run: npm publish发布前先校验版本是否已存在于仓库中,避免工作流重跑时失败:
yaml
- name: Check if version exists
id: check
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
VERSION=$(node -p "require('./package.json').version")
if npm view "${PACKAGE_NAME}@${VERSION}" version 2>/dev/null; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- if: steps.check.outputs.exists == 'false'
run: npm publishBootstrapping Existing Projects
已有项目接入
When adding release-please to a project with existing releases:
- Set to your current version
.release-please-manifest.json - Merge the setup PR with a commit
chore: - release-please will create the next release PR based on subsequent commits
- Alternatively, use footer to force a starting version
Release-As: x.x.x
给已有发布历史的项目添加release-please时:
- 将中的版本设置为当前最新版本
.release-please-manifest.json - 使用类型的提交合并配置PR
chore: - release-please会基于后续的提交生成下一个发布PR
- 也可以使用页脚强制指定初始版本
Release-As: x.x.x
Troubleshooting
故障排查
No Release PR Created
未生成发布PR
- Ensure commits since the last release include at least one releasable type (,
feat,fix)deps - Check that commits are on the correct branch (must match workflow trigger)
- Verify and manifest exist and are valid JSON
release-please-config.json - Check Actions logs for permission errors
- 确保上一次发布以来的提交中至少包含一个可触发发布的类型(、
feat、fix)deps - 检查提交是否推送到了正确的分支(必须与工作流触发分支匹配)
- 确认和manifest文件存在且是合法JSON
release-please-config.json - 查看Actions日志排查权限错误
Wrong Version Bump
版本升级不符合预期
- Review commit messages — won't trigger a release,
chore:triggers minorfeat: - Check for footers that may trigger an unexpected major bump
BREAKING CHANGE: - Use footer to override if needed
Release-As: x.x.x
- 检查提交信息——类型不会触发发布,
chore:类型触发次版本升级feat: - 检查是否存在页脚导致意外的主版本升级
BREAKING CHANGE: - 必要时使用页脚强制指定版本
Release-As: x.x.x
Pre-Release Flow
预发布流程问题
- Pre-releases use , not automatic push triggers
workflow_dispatch - The pre-release identifier is appended to the current version:
1.2.3-alpha.1 - Use the npm tag (or equivalent) for pre-releases,
nextfor stablelatest - See the pre-release template in
references/workflow-templates.md
- 预发布使用触发,而非自动推送触发
workflow_dispatch - 预发布标识符会追加到当前版本后:
1.2.3-alpha.1 - 预发布版本使用等npm标签(或对应平台的等效标签),稳定版本使用
next标签latest - 参考中的预发布模板
references/workflow-templates.md
Token / Permission Issues
令牌/权限问题
- Default works for release-please PRs and releases
GITHUB_TOKEN - Publishing to external registries requires dedicated secrets (, etc.)
NPM_TOKEN - GitHub Packages publishing uses with
GITHUB_TOKENpermissionpackages: write - For PyPI, use trusted publishers instead of API tokens
- 默认的足够支持release-please生成PR和Release
GITHUB_TOKEN - 发布到外部仓库需要专用密钥(等)
NPM_TOKEN - 发布到GitHub Packages使用并授予
GITHUB_TOKEN权限packages: write - PyPI发布推荐使用可信发布者而非API令牌
References
参考资料
| Reference | Description |
|---|---|
| Full Conventional Commits specification with examples and anti-patterns |
| Complete workflow templates for 9 ecosystems |
| All configuration options, release types, and Action inputs/outputs |
| release-please GitHub | Official documentation |
| Conventional Commits | Specification |
| 参考文件 | 说明 |
|---|---|
| 完整Conventional Commits规范,含示例和反模式 |
| 覆盖9种技术栈的完整工作流模板 |
| 全部配置选项、发布类型和Action输入输出说明 |
| release-please GitHub | 官方文档 |
| Conventional Commits | 规范官方文档 |