Skip to content

Commit e9e1420

Browse files
authored
feat: automate CHANGELOG.md updates from GitHub Release notes (#224)
`CHANGELOG.md` had no automated update mechanism — entries had to be added manually or not at all. This wires the existing `gh release create --generate-notes` output directly into `CHANGELOG.md` on every stable release. ## What changed ### `.github/release.yml` (new) Configures GitHub's auto-generated release note categories via PR labels: `breaking`, `feat`/`enhancement`, `fix`/`bug`, `docs`/`documentation`. Unlabelled PRs fall into "Other Changes"; `ignore-for-release` suppresses an entry entirely. ### `CHANGELOG.md` Replaced the placeholder with a Keep a Changelog header and an HTML comment marker that the workflow targets for insertion: ``` <!-- New entries are prepended automatically by the release workflow. --> ``` ### `.github/workflows/release.yml` — `update-changelog` job New job, runs after `release`, stable branches only (`is-release == 'true'`): 1. Fetches the release body: `gh release view <version> --json body --jq '.body'` 2. Inserts `## <version> — YYYY-MM-DD` + release notes immediately after the comment marker using `awk`, leaving the rest of the file intact 3. Commits and pushes back to `release/X.Y` (same pattern as the existing `promote-api-files` job) `merge-to-main` gains `update-changelog` in its `needs`, so the PR to `main` always includes the updated file. ### `.github/PULL_REQUEST_TEMPLATE.md` Added checklist item: apply one of the release-note label categories (`breaking` / `feat` / `fix` / `docs`). ### `docs/workflows.md` Added `update-changelog` row to the `release.yml` job table.
1 parent 05221ab commit e9e1420

5 files changed

Lines changed: 91 additions & 2 deletions

File tree

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
- [ ] XML doc comments updated for all public API changes
1717
- [ ] `dotnet format` run with no issues
1818
- [ ] README and `/samples` updated — if public API changed
19+
- [ ] PR label added (`breaking` / `feat` / `fix` / `docs`) — for changelog categorization

.github/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- ignore-for-release
5+
categories:
6+
- title: Breaking Changes
7+
labels:
8+
- breaking
9+
- title: New Features
10+
labels:
11+
- feat
12+
- enhancement
13+
- title: Bug Fixes
14+
labels:
15+
- fix
16+
- bug
17+
- title: Documentation
18+
labels:
19+
- docs
20+
- documentation
21+
- title: Other Changes
22+
labels:
23+
- '*'

.github/workflows/release.yml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,68 @@ jobs:
361361
is-preview: ${{ env.is-preview }}
362362
notes-start-tag: ${{ steps.determine-notes-start-tag.outputs.notes-start-tag }}
363363

364+
update-changelog:
365+
name: 'Update CHANGELOG.md'
366+
needs: [workflow-variables, release, versioning]
367+
if: ${{ needs.workflow-variables.outputs.is-release == 'true' }}
368+
runs-on: ubuntu-latest
369+
env:
370+
GH_TOKEN: ${{ github.token }}
371+
release-version: ${{ needs.versioning.outputs.release-version }}
372+
steps:
373+
- name: 'Checkout ${{ github.ref }}'
374+
uses: actions/checkout@v6
375+
with:
376+
ref: ${{ github.ref }}
377+
378+
- name: 'Fetch release notes'
379+
shell: bash
380+
run: |
381+
gh release view ${{ env.release-version }} --json body --jq '.body' > /tmp/release-notes.txt
382+
383+
- name: 'Prepend entry to CHANGELOG.md'
384+
shell: bash
385+
run: |
386+
release_date=$(date -u +%Y-%m-%d)
387+
{
388+
echo "## ${{ env.release-version }} — ${release_date}"
389+
echo ""
390+
cat /tmp/release-notes.txt
391+
echo ""
392+
} > /tmp/new-entry.txt
393+
awk '
394+
/<!-- New entries are prepended automatically by the release workflow. -->/ {
395+
print
396+
print ""
397+
while ((getline line < "/tmp/new-entry.txt") > 0) print line
398+
close("/tmp/new-entry.txt")
399+
next
400+
}
401+
{ print }
402+
' CHANGELOG.md > /tmp/changelog-new.md
403+
mv /tmp/changelog-new.md CHANGELOG.md
404+
405+
- name: 'Configure git identity'
406+
uses: './.github/actions/git/configure-identity'
407+
408+
- name: 'Commit and push CHANGELOG.md'
409+
shell: bash
410+
run: |
411+
git add CHANGELOG.md
412+
git diff --staged --quiet || (
413+
git commit -m "Update CHANGELOG.md for ${{ env.release-version }}" &&
414+
git pull --rebase origin ${{ github.ref_name }} &&
415+
git push
416+
)
417+
418+
- name: 'Write changelog summary'
419+
shell: bash
420+
run: |
421+
echo "✅ CHANGELOG.md updated for **${{ env.release-version }}**." >> $GITHUB_STEP_SUMMARY
422+
364423
merge-to-main:
365424
name: 'Merge ${{ github.ref_name }} into main'
366-
needs: [workflow-variables, release, versioning]
425+
needs: [workflow-variables, release, versioning, update-changelog]
367426
if: ${{ needs.workflow-variables.outputs.is-release == 'true' }}
368427
runs-on: ubuntu-latest
369428
permissions:

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3-
Release history is tracked via GitHub Releases.
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and release notes are generated automatically from merged pull requests.
47

58
See all releases at: <https://github.com/petesramek/polyline-algorithm-csharp/releases>
9+
10+
<!-- New entries are prepended automatically by the release workflow. -->

docs/workflows.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Version bumping runs independently via `bump-version.yml` (manual trigger).
8787
| `pack` | `versioning`, `build` | Packages binaries |
8888
| `publish-package` | `pack` | Publishes to NuGet.org (Production environment) |
8989
| `create-release` | `versioning`, `publish-package` | Creates a git tag + GitHub release with auto-generated notes |
90+
| `update-changelog` | `release` | Fetches release notes and prepends a new entry to `CHANGELOG.md` — stable releases only |
9091
| `generate-docs` | `versioning` | Builds DocFX site |
9192
| `publish-docs` | `generate-docs` | Deploys to GitHub Pages |
9293

0 commit comments

Comments
 (0)