Skip to content

fix: match CHANGELOG headers with date suffix in release workflow#590

Merged
abtreece merged 2 commits intomainfrom
chore/release-notes-from-changelog
Apr 23, 2026
Merged

fix: match CHANGELOG headers with date suffix in release workflow#590
abtreece merged 2 commits intomainfrom
chore/release-notes-from-changelog

Conversation

@abtreece
Copy link
Copy Markdown
Owner

@abtreece abtreece commented Apr 23, 2026

Summary

  • Fix awk extraction in release.yml that failed to match CHANGELOG headers with date suffixes (e.g. ### v0.41.1 (2026-04-22))
  • Use index() for exact string prefix matching with space boundary — avoids regex metachar issues and version prefix collisions
  • Revert redundant goreleaser before hook and release.header since the release workflow already handles extraction via gh release edit

Root cause

The release workflow used $0 == "### " tag which requires an exact line match, but CHANGELOG headers include a date suffix. This is why v0.41.1 published with empty release notes.

Test plan

  • Verified awk extraction matches ### v0.41.1 (2026-04-22) correctly
  • Verified v0.41.10 does not false-match against v0.41.1
  • Verified regex metachar in dots (v0X41X1) no longer false-matches
  • goreleaser check validates config

Add a before hook that extracts the current version's section from
CHANGELOG and a release.header reference so goreleaser includes it
in GitHub release notes automatically.
Copilot AI review requested due to automatic review settings April 23, 2026 03:05
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.06%. Comparing base (a5fc549) to head (09db851).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #590   +/-   ##
=======================================
  Coverage   67.06%   67.06%           
=======================================
  Files          53       53           
  Lines        7035     7035           
=======================================
  Hits         4718     4718           
  Misses       2090     2090           
  Partials      227      227           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the release automation so GitHub release notes can be populated from the curated CHANGELOG content during GoReleaser runs.

Changes:

  • Add a GoReleaser before.hooks step that extracts the current tag’s CHANGELOG section into a temp markdown file.
  • Configure GoReleaser release.header to use the extracted content as the release header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .goreleaser.yml Outdated
before:
hooks:
- go mod tidy
- bash -c 'awk "/^### v{{ .Version }}/{found=1; next} /^### v/{if(found) exit} found" CHANGELOG > /tmp/release_header.md'
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The awk match ^### v{{ .Version }} is a prefix regex, so version 0.41.1 would also match a ### v0.41.10 ... section (and . is treated as “any char”). Consider matching the exact section header (e.g., compare the full line or enforce a boundary like ([[:space:]]|$) after the version) to avoid extracting the wrong release notes.

Suggested change
- bash -c 'awk "/^### v{{ .Version }}/{found=1; next} /^### v/{if(found) exit} found" CHANGELOG > /tmp/release_header.md'
- bash -c "awk -v ver='{{ .Version }}' '\$0 == \"### v\" ver {found=1; next} /^### v/{if(found) exit} found' CHANGELOG > /tmp/release_header.md"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Valid point. Reverted the goreleaser hook entirely — the release workflow already handles extraction. Fixed the workflow's awk to use index() for exact string prefix matching with boundary check, avoiding both the regex metachar issue and prefix collision.

Comment thread .goreleaser.yml Outdated
before:
hooks:
- go mod tidy
- bash -c 'awk "/^### v{{ .Version }}/{found=1; next} /^### v/{if(found) exit} found" CHANGELOG > /tmp/release_header.md'
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hook will succeed even if no matching CHANGELOG section is found (producing an empty /tmp/release_header.md), which can lead to publishing a release with blank notes. Consider making the extraction fail the build when the section is missing/empty (e.g., have awk exit non-zero if found was never set, and/or check the output file is non-empty).

Suggested change
- bash -c 'awk "/^### v{{ .Version }}/{found=1; next} /^### v/{if(found) exit} found" CHANGELOG > /tmp/release_header.md'
- bash -c 'awk '"'"'/^### v{{ .Version }}/{found=1; next} /^### v/{if(found) exit} found {print; printed=1} END {if(!found || !printed) exit 1}'"'"' CHANGELOG > /tmp/release_header.md && test -s /tmp/release_header.md'

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the goreleaser hook. The existing release workflow already warns on empty extraction (line 80-82) which is sufficient — a missing CHANGELOG section shouldn't block artifact publishing.

Comment thread .goreleaser.yml Outdated

release:
prerelease: auto
header: /tmp/release_header.md
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This release.header change likely won’t achieve the PR goal in CI because the current GitHub Actions release workflow already extracts notes into /tmp/release_notes.md and then overwrites the GitHub release body via gh release edit --notes-file ... after GoReleaser runs. To actually populate release notes via GoReleaser, the workflow should be updated to remove/align that post-step (or it will continue to override whatever GoReleaser generates).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Reverted the goreleaser changes and fixed the actual bug in the workflow instead — the awk was using exact line match ($0 == "### " tag) but CHANGELOG headers include a date suffix (e.g. ### v0.41.1 (2026-04-22)). Now uses index() for exact string prefix matching with a space boundary.

The awk extraction in release.yml used exact line match ($0 == "### vX.Y.Z")
but CHANGELOG headers include a date suffix (### v0.41.1 (2026-04-22)).
Use index() for exact string prefix matching with boundary check instead.

Revert redundant goreleaser before-hook and release.header since the
release workflow already handles CHANGELOG extraction via gh release edit.
@abtreece abtreece changed the title chore: populate GitHub release notes from CHANGELOG fix: match CHANGELOG headers with date suffix in release workflow Apr 23, 2026
@abtreece abtreece merged commit b208352 into main Apr 23, 2026
15 checks passed
@abtreece abtreece deleted the chore/release-notes-from-changelog branch April 23, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants