Repository navigation
chore(ci): generate release notes from conventional commits - #62
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: CHANGES_REQUESTED
全体の設計(tag push → verify → publish → release で notes 付き release、notes 専用 workflow、contents: write の分離、git-cliff の pin)は要望どおりで良いと思います。ただ、実際の squash commit(PR 本文が commit 本文になる)で notes を作ると、Dependabot の 1 行まとめが壊れることを確認しました。must-fix 1 件、should-fix 2 件です。
確認したこと
actionlint(全 workflow)・shellcheck .github/scripts/release-notes.sh: 指摘なし。- git-cliff 2.14.2 は公式 release の
aarch64-apple-darwinの tar を取得し、sha512 が一致することを確認してから使用。taiki-e/install-action@83ac0ad…はv2.87.22の tag の commit と一致。その manifest にあるgit-cliff2.14.2(x86_64 musl)の sha256fa21e2fc…も、公式 tar の実際の値と一致した(公式の.sha512でも OK)。 release-notes.sh v0.1.0 sha256:b611…の出力は CI の artifactrelease-notes/v0.1.0.mdと 完全に一致。release-notes.sh v0.1.1は 1 行だけ違う。CI 側には- Merge e039f10… into 0eacfe4…がある(PR の merge ref から生成しているため。nit 1)。- 使い捨ての clone で
v0.2.0-rc.1→v0.2.0-rc.2→v0.2.0を打って確認(push なし)。rc.1 は v0.1.0 から、rc.2 は rc.1 から、v0.2.0 は v0.1.0 から(rc の分を畳み込む)、compare リンクもそれぞれ正しい。前回 tag の選び方は OK。 - workflow の安全性:
- tag・input・commit message は
${{ }}で shell に直接展開されておらず、すべて env 経由で、quote されている。 - notes は
--notes-fileで渡しているので、PR タイトルから shell injection にはならない。 contents: writeを持つのはrelease(main の祖先の tag の code のみ実行)とupdate(repository の code を実行しない)だけ。update=trueで main / tag 以外から実行した場合と GHCR に image が無い場合は、notesjob が失敗してupdateは skip される。publish.outputs.digestはTagstep で tag の指す digest と一致を確認済みの値で、受け渡しも正しい。
- tag・input・commit message は
must-fix
1. Dependabot のまとめ行から PR リンクが消える(本文のある commit)
link_parsers の pattern が …\)\)$ で終わっています。git-cliff は link parser を 本文を含む commit message 全体に当てるので、$ が本文の末尾にしか一致しません。この repo の squash merge は PR 本文を commit 本文にします(template の注記と 0eacfe4 のとおり)。Dependabot の PR には必ず本文(Bumps … / updated-dependencies: / Signed-off-by:)があるので、実際の Dependabot の commit ではリンクが 1 つも取れません。
再現(使い捨て clone、本文ありの chore(deps): … (#71) と (#72)):
### Dependencies
- 2 dependency updates (Dependabot):,本文なしの commit 1 件と本文ありの commit 1 件では [#80](…), となり、1 件だけ載って末尾に , が残ります。PR 説明の「Dependabot の 2 件は 1 行になり」は、本文なしの commit で確認したものだと思います。
修正案(1 行目の末尾の ([#N](…)) だけを取る。確認済みで、v0.1.0 の出力は変わりません):
link_parsers = [
{ pattern = '\A[^\n]*\(\[#([0-9]+)\]\(https://github\.com/nishide-dev/texrun/pull/[0-9]+\)\)(?m:$)', href = "https://github.com/nishide-dev/texrun/pull/$1", text = "#$1" },
]修正後: - 2 dependency updates (Dependabot): [#71](…), [#72](…)
併せて、PR 番号の無い chore(deps)(直 push など)が混ざっても , が残らないようにする(nit 2)か、本文ありの Dependabot 形式の commit を含む fixture を PR の notes job で生成して確かめると、回帰を防げます。
should-fix
2. Breaking changes に footer の本文がそのまま出る(日本語・後続の段落・PR リンクなし)
template が commit.breaking_description | default(value=commit.message) を使っています。CONTRIBUTING.md の例のとおり footer を日本語で書くと、英語の notes にそのまま日本語の行が入ります。また、この repo の PR 本文は末尾が 🤖 Generated with [Claude Code](…) なので、footer の後の段落まで breaking_description に含まれ、notes の構造が崩れます。footer 由来の行には PR リンクも付きません。
再現:
### Breaking changes
- **core**: Rename the engine trait ([#73](…))
- **cli**: `--json` は削除され、`--format json` に置き換えられた。
- **cli**: --quiet is removed.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
### Features修正案: Breaking changes の行も commit のタイトル(PR タイトル)で書く。
- {% if commit.scope %}**{{ commit.scope }}**: {% endif %}{{ commit.message | split(pat="\n") | first | trim | upper_first }}
(確認済み: - **cli**: Rename --json flag to --format json ([#74](…)) になります)
footer の説明(移行方法)を載せたい場合は、「footer は英語で 1 段落、PR 本文の最後(attribution より後)に書く」と CONTRIBUTING.md に明記する必要があり、運用上は難しいと思います。タイトルにするのが無難です。
3. Conventional でない commit は本文ごと notes に入る
conventional として parse できない commit では commit.message が本文を含む全文になります。そのため、filter_unconventional = false で Other changes に残す設計だと、PR 本文(日本語の長文)がそのまま notes に流れ込みます。例: GitHub の Revert ボタンで作った PR を merge した場合(Revert "…" (#76) + This reverts commit …)や、pr-title を通らずに入った commit。
再現:
- Revert "feat(cli): drop --quiet ([#75](…))" ([#76](…))
This reverts commit abc.修正案: 各行を commit.message | split(pat="\n") | first | trim | upper_first にする(上の 2 と同じ式。conventional な commit では message が description だけなので影響なし。確認済み)。
nit
- PR 上のプレビューに
Merge <sha> into <sha>の行が入る(pull_requestの checkout が merge ref のため)。release-notes.ymlの checkout にref: ${{ github.event.pull_request.head.sha }}を付けると、「main に squash した後」に近いプレビューになります(tag はfetch-depth: 0で取れます)。 - Dependencies の行の
,の扱い:commits | filter(attribute="links")相当で、リンクのある commit だけを並べ、件数と分ける(または、リンクの無いものは短い SHA を出す)と安全です。 - PR タイトルに
@userがあると、release notes で mention になり通知されます。CONTRIBUTING.md の注意に一言あってもよいです(<img …>やjavascript:のリンクは GitHub が sanitize するので、セキュリティ上の問題ではありません)。 - docs/development.md の「
update=trueは main か tag の上でのみ」について。この PR より前の tag(v0.1.0)にはrelease-notes.ymlも script も無いので、tag の上では dispatch できません。「通常は--ref main」と書くのが正確です。 - docs/development.md の「ローカルで確かめる」に、
jqも必要なことを追記(script の冒頭のコメントには書いてあります)。 - (PR の補足にある提案に同意)
updatejob にenvironmentを付けると、branch 上で workflow を書き換えて dispatch した場合も含めて、release の書き換えを保護できます。必須ではありません。
設計について(問題なし)
- 既存 release の notes を上書きする点は、notes が git の履歴と GHCR の digest から決定的に作られるので、再実行は冪等です。手の編集が消えることも docs/development.md に明記されています。
- engine-image.yml の
releaseは、notes を生成して summary に出してから create / edit → upload の順です。再実行時に asset が残っていると upload が失敗する点は、従来どおり docs に書かれています。
Co-Authored-By: Claude Opus 5.5 <[email protected]>
nishide-dev
left a comment
There was a problem hiding this comment.
Verdict: APPROVE
db3e42a の再レビューです。前回の must-fix 1 件と should-fix 2 件はすべて解消し、nit 1〜5 も対応されています。残るのは任意の nit 2 件だけです。
確認したこと
actionlint(全 workflow)、shellcheck .github/scripts/release-notes.sh .github/scripts/release-notes-test.sh: 指摘なし。- fixture test の妥当性:
- 新しい head で
release-notes-test.shはrelease notes: as expected(ローカルの git-cliff 2.14.2、公式 binary で sha512 を確認済み)。CI のnotesjob のTeststep も同じ結果。 cliff.tomlだけを e039f10(修正前)に戻して同じ test を実行すると、期待どおり失敗した。差分は前回の指摘 4 点すべてに出る。- Breaking changes が日本語の footer と
🤖 Generated with …の段落になる。 @octocatが code にならない。- Revert の本文が notes に入る。
3 dependency updates (Dependabot):,,になる。
- Breaking changes が日本語の footer と
- fixture は main の実際の squash merge の形(PR 本文付き、Dependabot の本文付き、PR 番号無しの deps、日本語の footer の後に attribution、Revert ボタン形式)を押さえていて、回帰 test として十分。
- 新しい head で
- v0.1.0 の notes は変わらない: 新しい head でローカルに生成した notes が、前回の CI の artifact
v0.1.0.mdと完全に一致。新しい CI の artifact(run 37507632302)のv0.1.0.mdとも一致。 - 前回の再現の再実行(使い捨て clone の同じ履歴に、新しい
cliff.tomlを当てた):- Dependabot(本文付き)は
- 2 dependency updates: [#71](…), [#72](…)になる。本文ありと本文なしの混在でも[#80](…), [#81](…)。 - Breaking changes は 3 件ともタイトルと PR リンクで出る(
--jsonの footer もRename --json flag to --format json ([#74](…)))。 - Revert は本文が消えて 1 行になる。
@nishide-devは`@nishide-dev`になる。 - rc / 正式版の前回 tag の選び方と compare リンクは前回どおり正しい。
- Dependabot(本文付き)は
- PR のプレビュー: head sha で checkout するようになり、新しい artifact の
v0.1.1.mdからMerge … into …の行が消えた。 - docs: CONTRIBUTING.md(タイトルだけが載る、
@nameを避ける)と docs/development.md(PR 番号の無いものは件数だけ、本文や footer は載らない、jqが要る、通常は--ref mainで実行する、fixture test と--update)が、実装と一致している。
nit(任意。merge を妨げない)
@nameの preprocessor は、PR タイトルの code span の中にある、空白に続く@にも当たります。例:fix: handle `foo @bar`は`foo `@bar`` になり、code span が崩れます。preprocessor は commit message 全体に当たるのでまれなケースで、CONTRIBUTING.md でタイトルに@nameを書かない運用にしているため、実害はほぼありません。気になる場合は、fixture に 1 件追加して挙動を固定しておく程度で十分です。- 前回の nit 6(
updatejob にenvironmentを付ける)は引き続き任意です。
概要
v*の tag を push するだけで、検証 → engine image の公開 → release notes 付き の GitHub release の作成(source tar 添付)まで完了するようにする。release notes は前の版の tag から今回の tag までの commit(= squash merge した PR タイトル、Conventional Commits)を git-cliff で分類して生成し、インストール方法・image の tag / digest・gh attestation verify・source tar の説明を定型で付ける。既存 release の notes だけを作り直す workflow も追加する(v0.1.0 の notes を埋めるのに使う)。変更内容
cliff.toml(新規): git-cliff の設定。type で分類(feat→ Features /fix→ Bug fixes /perf→ Performance /docs→ Documentation /refactor・test・build・chore→ Other changes)。chore(deps)は Dependencies に「N dependency updates: #a, #b」の 1 行にまとめる(PR 番号はタイトル行の末尾の(#N)だけから取る。番号の無いものは件数にだけ数える)。!/BREAKING CHANGE:は Breaking changes にも載せる。Conventional でない commit も Other changes に残す。すべての行は commit のタイトル(1 行目 = PR タイトル)だけから作り、PR 本文や footer の文面は載せない。末尾の(#N)を PR へのリンクにし、@nameは mention にならないよう code にし、前の版との compare リンクを付ける。.github/scripts/release-notes-test.sh/release-notes-test.expected.md(新規): 使い捨ての repository に main の squash merge と同じ形の fixture の commit(PR 本文付き、実際の Dependabot 形式の本文付き(単独・group)、PR 番号の無いchore(deps)、日本語のBREAKING CHANGE:footer + attribution、GitHub の Revert、@nameを含むタイトル)を作り、notes の「What's changed」を期待値と比べる。PR のnotesjob で毎回実行する。.github/scripts/release-notes.sh(新規):release-notes.sh <tag> [<digest>]で notes の Markdown を出力する。--ignore-tags '^v.*-')、prerelease は直前の tag から、最初の版は全履歴。git-cliff の--contextから対象 tag の release だけを選んで--from-contextで描画するので、HEAD が tag より先(main)でも同じ notes になる。.github/workflows/engine-image.ymlpublishがdigestを output する。releaseが checkout(fetch-depth: 0)→ git-cliff(taiki-e/install-actionを SHA pin、[email protected]。install-action が checksum を検証)→ notes 生成(job summary にも出す)→ release の作成(--notes-file。版に-があれば prerelease にする既存の扱いを維持)。.github/workflows/release-notes.yml(新規): notes の生成だけを行う workflow。image の公開・release の作成はしない。pull_request(cliff.toml・script・この workflow の変更時): fixture の test の後、PR の head commit(merge ref ではなく。Merge … into …の行が入らない)で、最後の tag(現状 v0.1.0、全履歴)の notes と、次の版(patch + 1)としての「最後の tag 以降」の notes を job summary と artifactrelease-notesに出す。digest は GHCR から引く(未公開の版は placeholder)。workflow_dispatch(tag、update):update=false(既定)は dry run。update=trueはgh release edit --notes-fileで既存 release の notes を置き換える(main か tag 上の実行のみ。image が GHCR に無い版は失敗)。notesjob はcontents: read。書き込むupdatejob だけがcontents: writeで、repository の code は実行しない(artifact を受け取ってgh release editするだけ)。docs/development.md: release 手順を「tag を push するだけ」に更新し、「release notes」節(分類の規則、notes の文面は PR タイトルで決まること、ローカルでの生成方法、作り直し方)を追加。CONTRIBUTING.md: PR タイトルが release notes の 1 行になること、type / description の書き方の注意、notes の PR check を追記。docs/security.md(権限の記述)、docs/engine-image.md(digest は release notes に載る)を追随。設計判断
.github/release.ymlではなく): この repo は PR にラベルを付けない運用で、GitHub の自動生成はラベルでしか分類できない。git-cliff は commit の type で分類でき、PR タイトル = commit タイトルの運用にそのまま合う。API を使わず(--offline)git の履歴だけで決まるので、PR 上やローカルでも同じ結果を再現できる。cliff.tomlからgit cliffでいつでも全履歴を出せる。workflow_dispatchは image の公開と結び付いているので、notes だけの経路を分けた。image は再公開せず、digest は GHCR にある既存の版から引く。releasejob で生成する。設定の誤りは PR 上のRelease notes / notesで先に検出する。万一releaseで失敗しても image は公開済みで、gh run rerun --failedでやり直せる(既存の手順どおり)。2.14.2を両 workflow で固定(install-action の manifest の sha256 で検証)。install-action 自体は SHA pin で、Dependabot の対象。確認方法
actionlint(全 workflow)、shellcheck .github/scripts/release-notes.shrelease-notes.sh v0.1.0 sha256:b611…→ 下記(v0.1.0 までの全履歴、32 commit)release-notes.sh v0.1.1→ v0.1.0 以降の差分(この PR の commit のみ)のプレビューv0.2.0-rc.1/v0.2.0-rc.2/v0.2.0を打って確認: rc.2 は rc.1 からの差分、v0.2.0 は v0.1.0 からの全部(rc の分を畳み込む)。tag が HEAD の祖先でない場合・semver でない tag・不正な digest はエラーになるrelease-notes-test.sh: 期待値どおり(下記)。修正前のcliff.tomlに戻して実行すると、Dependabot の行が3 dependency updates (Dependabot):,,に、Breaking changes が日本語の footer +🤖 Generated with …に、Revert の行が本文付きに、@octocatが mention になり、test が失敗することを確認したCONTRIBUTING.md/docs/development.md: タイトルだけが載ること、@nameを書かないこと、jqが要ること、updateは通常--ref mainで実行すること(v0.1.0 の tag の上には workflow が無い)、fixture の test を追記Release notes / notesが、v0.1.0 と v0.1.1(プレビュー)の notes を job summary と artifact に出す(GHCR から v0.1.0 の digest を引く)workflow_dispatchの dry run は、新規 workflow が default branch に入るまで dispatch できないため、merge 後にgh workflow run release-notes.yml --ref main -f tag=v0.1.0で確認する(PR 上のpull_requestの実行が同じ生成を行う)生成例: v0.1.0(digest は GHCR の実際の値)
v0.1.0 の notes(全文)
生成例: v0.1.0 以降の main の差分(次の版のプレビュー)
(以下の Install / Engine image / Source は v0.1.0 と同じ形で、digest は placeholder。squash merge 後は 1 commit になる)
生成例: fixture(
release-notes-test.expected.md)補足
gh workflow run release-notes.yml --ref main -f tag=v0.1.0(dry run、summary で確認)の後にgh workflow run release-notes.yml --ref main -f tag=v0.1.0 -f update=true。release-notes.ymlのupdatejob にも、engine-image.yml と同様にenvironmentを付けることを検討できる(docs/security.md の「release の入口」)。🤖 Generated with Claude Code