用途
该技能使用 changelogithub 读取两个标签之间的 Conventional Commits,创建(或更新)GitHub Release,并生成格式化的变更日志。
工作流配置
触发与权限
on:
push:
tags:
- 'v*'
permissions:
contents: write # required — default contents:read cannot create releases
触发条件为推送 v* 标签。权限需要 contents: write,因为默认的 contents:read 无法创建 Release。
变更日志步骤
将 changelogithub 作为最后一步运行——放在 npm publish(如有)之后——这样发布失败时不会产生悬空的 GitHub Release:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # full tag history required; shallow clone produces empty changelog
- uses: pnpm/action-setup@v6
- name: Generate changelog
run: pnpm dlx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
checkout 需要设置 fetch-depth: 0,因为需要完整的标签历史;浅克隆会生成空的变更日志。
Conventional Commits
changelogithub 按类型对条目分组,并将破坏性变更置于顶部:
| Commit prefix | Changelog section |
|---|---|
feat: |
Features |
fix: |
Bug Fixes |
chore: |
Chores |
feat!: / chore!: |
Breaking Changes (top) |
不符合约定的提交会被变更日志忽略。
推送标签前预览
pnpm dlx changelogithub --dry
参考
如需结合 npm publish 与变更日志生成的完整端到端工作流,可参见 automate-npm-release/EXAMPLE_WORKFLOW.yml(若该技能已在本地安装)。