fix(release): 修复 git-cliff PR 元数据令牌

- 修复 auto-tag 中 git-cliff 使用 PAT_TOKEN 导致 PR 读取权限不受 job permissions 约束的问题

- 修复 semantic-release trace 中重复日期标题触发 MD024 的问题

- 更新 SEMREL-RP-007 跟踪记录,说明发布说明生成的 token 分工与后续恢复点
This commit is contained in:
gewuyou 2026-05-04 14:19:40 +08:00
parent 53870c1f92
commit 478072acc3
3 changed files with 20 additions and 12 deletions

View File

@ -72,7 +72,7 @@ jobs:
env:
OUTPUT: PREVIEW_RELEASE_NOTES.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
- name: Write preview summary
env:
@ -159,7 +159,7 @@ jobs:
env:
OUTPUT: PUBLISHED_RELEASE_NOTES.md
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
- name: Write release summary
env:

View File

@ -17,6 +17,8 @@
- 当前阶段:修复 git-cliff 发布说明 PR 链接缺失
- 当前焦点:
- `.github/workflows/auto-tag.yml` 的 preview / release job 增加 `pull-requests: read`
- `.github/workflows/auto-tag.yml``git-cliff-action` 改用 `${{ github.token }}` 读取 PR 元数据,`PAT_TOKEN`
只保留给 `semantic-release` 的 dry-run push 探测与真实打 tag
- `.github/workflows/publish.yml` 的 GitHub Release job 增加 `pull-requests: read`
- 保持 `.github/cliff.toml``by @user in #PR` 模板不变,只补足 GitHub PR 元数据读取权限
- `fix/release-notes-pr-links` 分支映射到当前 active topic
@ -35,6 +37,8 @@
working-directory 或 artifact 路径,需要同步复查 `body_path`
- `git-cliff-action` 依赖 GitHub API 补充 `commit.remote.pr_number`;生成 release notes 的 workflow job 必须具备
`pull-requests: read`,否则模板只能稳定输出作者,不能稳定输出 `in #PR`
- `auto-tag.yml` 中 job 级 `permissions` 只约束 `${{ github.token }}`,不约束 `${{ secrets.PAT_TOKEN }}`;生成
release notes 时必须使用 `${{ github.token }}` 才能让 `pull-requests: read` 声明真正生效
## 已完成
@ -48,8 +52,8 @@
`ai-plan/public/semantic-release-versioning/archive/todos/semantic-release-versioning-rp004-2026-05-02.md`
- `SEMREL-RP-005` 已扩展 `deps` / `security` 的 patch 发布规则,并同步提交规范文档
- `SEMREL-RP-006` 已根据 PR review 复核结果补齐 release notes 类型映射,避免 patch 发布原因只触发版本而不进入 notes
- `SEMREL-RP-007` 已为所有 `git-cliff-action` release notes 生成 job 补齐 PR 读取权限,避免未来 GitHub Release
正文缺失 PR 链接
- `SEMREL-RP-007` 已为所有 `git-cliff-action` release notes 生成 job 补齐 PR 读取权限,并让 `auto-tag.yml`
`git-cliff-action` 改用 `${{ github.token }}`,避免未来 GitHub Release 正文缺失 PR 链接
## 验证
@ -65,7 +69,8 @@
fetch 会 clobber 本地既有 tags 而终止,未暴露 `presetConfig.types` 配置解析错误
- `dotnet build GFramework.sln -c Release` 通过,`0 warning / 0 error`
- `SEMREL-RP-007` 已完成本地验证:
- workflow 权限静态检查通过,所有 `git-cliff-action` 所在 job 均声明 `pull-requests: read`
- workflow 权限静态检查通过,所有 `git-cliff-action` 所在 job 均使用具备 `pull-requests: read`
`${{ github.token }}`
- `.github/cliff.toml` 通过 Python `tomllib` 解析
- `python3 scripts/license-header.py --check` 通过
- `dotnet build GFramework.sln -c Release` 通过,`0 warning / 0 error`
@ -74,5 +79,5 @@
## 下一步
1. 提交 `SEMREL-RP-007` 的 workflow 权限修复
1. 推送 `SEMREL-RP-007` 的 PR review 修复,并重新抓取 PR review 确认重复标题线程和 PAT token 说明已收敛
2. 如后续需要回填当前 GitHub Release 正文,使用带 PR read 权限的 GitHub CLI 或 API token 重新生成并更新 notes

View File

@ -9,23 +9,26 @@
- `.github/cliff.toml``print_commit` 只有在 `commit.remote.pr_number` 存在时才追加 PR 链接
- `auto-tag.yml``publish.yml``git-cliff-action` job 只声明了 `contents` / `packages` 权限,没有显式
`pull-requests: read`
- PR review 补充指出 `auto-tag.yml` 里的 `git-cliff-action` 实际接收 `PAT_TOKEN`job 级 `pull-requests: read`
不会约束该 token
- 本地复核结论:
- 模板本身已经包含 `by @user in #PR` 输出,不需要改 release notes 格式
- 修复点应放在 workflow permissions确保 git-cliff 能通过 GitHub API 稳定补全 PR 元数据
- `publish.yml` 已对 `git-cliff-action` 使用 `${{ github.token }}`job 级 `pull-requests: read` 能直接生效
- `auto-tag.yml` 应仅让 `semantic-release` 继续使用 `PAT_TOKEN`,让 `git-cliff-action` 改用带 job 权限的
`${{ github.token }}`,避免 PR 元数据读取能力取决于 PAT 创建时的额外 scope
- 当前环境未安装 `git-cliff``gh`,无法在本地直接重渲染并回填已发布的 GitHub Release 正文
- 已应用修复:
- `.github/workflows/auto-tag.yml` 的 preview / release job 增加 `pull-requests: read`
- `.github/workflows/auto-tag.yml` 的 preview / release `git-cliff-action` 改用 `${{ github.token }}`
- `.github/workflows/publish.yml``create-release` job 增加 `pull-requests: read`
- `ai-plan/public/README.md` 新增 `fix/release-notes-pr-links``semantic-release-versioning` 的 active topic 映射
- 验证:
- workflow 权限静态检查通过,所有 `git-cliff-action` 所在 job 均声明 `pull-requests: read`
- workflow 权限静态检查通过,所有 `git-cliff-action` 所在 job 均使用具备 `pull-requests: read``${{ github.token }}`
- `.github/cliff.toml` 通过 Python `tomllib` 解析
- `python3 scripts/license-header.py --check` 通过
- `dotnet build GFramework.sln -c Release` 通过,`0 warning / 0 error`
- 下一步是提交本轮 workflow 权限修复;如需回填 v0.3.0 Release 正文,需要在具备 `git-cliff` / `gh`
或 GitHub release API 能力的环境中执行。
## 2026-05-04
- 下一步是推送本轮 PR review 修复并重新抓取 PR review确认重复标题线程和 PAT token 说明已收敛;如需回填
v0.3.0 Release 正文,需要在具备 `git-cliff` / `gh` 或 GitHub release API 能力的环境中执行。
### PR review notes 类型映射修复SEMREL-RP-006