ci(release): 发版后给本版本 PR 自动留「Released in vX.Y.Z」评论 - #652
Merged
Conversation
GitHub 原生侧栏那个「released in vX.Y.Z」徽标判定用的是 PR 分支的原始 head commit,squash 合并会把它变成孤儿 commit(即便 squash 出的新 commit 能从 tag 到达也不认)→ 用 squash 的 PR 永远不显示该徽标。实测 v3.7.1:#650/#631(merge commit)显示、#645/#646/#629(squash)不显示。 为「保持 squash 又能在 PR 上看到进了哪个版本」,发版后给本版本包含的每个 PR 留一条可见可点的时间线评论「🚀 Released in vX.Y.Z + release 链接」 作为等效替代。 实现(复用现有机制,不新增 API 扫描): - PR 列表直接来自 changelog 步骤已算好的 $RAW(type==pr 行去重),写到 released_prs.txt 交给新步骤,不再多打一次 /commits/{sha}/pulls - 只在 stable(latest)发版评论:canary/beta/rc/next 是灰度,评论会先刷 -canary 再刷正式版、既噪又误导,且对齐原生徽标只关心正式 Release 的语义 - fail-soft:npm+Release 此时已发布,评论失败不能让 job 失败 → continue-on-error + 单 PR 内部容错 - 幂等:重跑(如签名恢复 re-run)不重复刷,靠隐藏标记 `<!-- released-in:vX.Y.Z -->` 先查后发 - FD 3 读 PR 列表而非 stdin,避免循环内 gh 子进程吃掉后续 PR 行漏评论 - 纯直推(列表为空)自然 no-op - 新增 pull-requests: write 权限(原 job 仅 contents: write) 验证:python yaml.safe_load 通过;bash 端到端模拟证 PR 抽取去重、幂等 跳过、FD3 隔离无 stdin 泄漏(629 评论/645 幂等跳过/650 评论,无 LEAK)。 影响面:纯改 release.yml 的 release job,只在 stable tag-push 时多跑一步 评论;不动 npm publish/Release 创建/桌面资产/dist-tag 回滚 workflow。 不涉及运行时代码、跨平台/CLI/后端。 Co-Authored-By: Riff <noreply@riff.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景 / 为什么
GitHub 原生侧栏那个「released in vX.Y.Z」徽标,判定用的是 PR 分支的原始 head commit 能否从 tag 回溯 —— 而 squash 合并会把 PR 压成一个全新 commit,原始 head commit 变成孤儿(即便 squash 出的新 commit 能从 tag 到达,GitHub 也不认)→ 用 squash 的 PR 永远不显示该徽标。
实测 v3.7.1 佐证:
(release notes 里能提到 #645 等,是 CI 从 commit message 的
(#N)文本抓的,与徽标是两套独立机制。)申晗希望保持 squash 的线性历史,又能在 PR 上看到「进了哪个版本」。原生二者互斥,故用发版后自动评论作为 squash 兼容的等效替代。
改了什么
发版后给本版本包含的每个 PR 留一条可见可点的时间线评论:
实现(复用现有机制,不新增 API 扫描)
$RAW(type==pr行)去重,写到released_prs.txt交给新步骤——不再多打一次/commits/{sha}/pullsif: steps.dist_tag.outputs.tag == 'latest',与同 job 已有 3 处 guard 用法一致。canary/beta/rc/next 是灰度,若也评论会先刷-canary再刷正式版、既噪又误导,且对齐原生徽标只关心正式 Release 的语义continue-on-error: true+ 单 PR 内部容错<!-- released-in:vX.Y.Z -->先查后发while read <&3 … done 3< file而非 stdin,避免循环内gh子进程吃掉后续 PR 行导致漏评论pull-requests: write权限(原 job 仅contents: write)实际验证
python3 yaml.safe_load解析通过;ifguard 与同 job 已有 3 处dist_tag == 'latest'用法一致gh pr comment尝试读 stdin 也无 LEAK、不漏 PR:645出现两次(merge-commit 多子 commit 场景)→ 收敛为一条影响面
release.yml的releasejob,只在 stable tag-push 时多跑一步评论