codegen: Improve changelog handling

This commit is contained in:
Taiki Endo
2026-05-05 06:55:02 +09:00
parent 07924c7415
commit 11569735dc
2 changed files with 9 additions and 3 deletions

View File

@@ -32,7 +32,7 @@ concurrency:
jobs:
manifest:
uses: taiki-e/github-actions/.github/workflows/gen.yml@75415970465917c31d702710acd9c9248b9af314 # main
uses: taiki-e/github-actions/.github/workflows/gen.yml@a6df8c9ea0038c730f138f0f849d692cf387ea4e # main
permissions:
contents: write # for creating branch for pr
pull-requests: write # for gh pr review --approve
@@ -46,3 +46,4 @@ jobs:
automerge: true
install-rust: true
install-cosign: true
install-parse-changelog: true

View File

@@ -30,9 +30,14 @@ for manifest in manifests/*.json; do
git stash pop
new_version=$(jq -r '.latest.version' "${manifest}")
if [[ "${old_version}" != "${new_version}" ]]; then
# TODO: If there is a line about updating the same tool in the "Unreleased" section, replace it.
unreleased=$(parse-changelog CHANGELOG.md Unreleased)
msg="Update \`${name}@latest\` to ${new_version}"
sed -Ei "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n- ${msg}./" CHANGELOG.md
if grep -Eq "^- Update \`${name}@latest\` to " <<<"${unreleased}"; then
# If there is a line about updating the same tool in the "Unreleased" section, replace it.
sed -Ei "0,/^- Update \`${name}@latest\` to .*/s//- ${msg}./" CHANGELOG.md
else
sed -Ei "s/^## \\[Unreleased\\]/## [Unreleased]\\n\\n- ${msg}./" CHANGELOG.md
fi
git add "${manifest}" CHANGELOG.md
else
msg="Update ${name} manifest"