-
-
Notifications
You must be signed in to change notification settings - Fork 241
fix(changelog): remove stale Unreleased entry and guard against manual entries #5369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
44f063e
fix(changelog): remove stale Unreleased entry and guard against manua…
jamescrosswell 973037c
Apply suggestion from @jamescrosswell
jamescrosswell 4859458
fix(changelog): guard fails on any non-empty Unreleased body, not jus…
jamescrosswell 4ba87b4
Merge remote-tracking branch 'origin/changelog-unreleased-ci-guard' i…
jamescrosswell c5771de
chore: collapse double blank line in CONTRIBUTING changelog section
jamescrosswell 739de6c
docs: mention '### Changelog Entry' PR-description override
jamescrosswell 7ba2869
Apply suggestions from code review
jamescrosswell cb6a807
chore: add changelog-guard workflow and verify-changelog script to so…
jamescrosswell 9557da7
docs(agents): note that submodules must be checked out first
jamescrosswell b9cdf5f
fix(changelog): report real CHANGELOG.md line numbers for offending e…
jamescrosswell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| name: Changelog Guard | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - release/** | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| no-manual-unreleased-entries: | ||
| name: No manual "## Unreleased" entries | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | ||
| - name: Verify CHANGELOG.md has no manual "## Unreleased" entries | ||
| run: ./scripts/verify-changelog.sh | ||
|
sentry[bot] marked this conversation as resolved.
|
||
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Verifies that CHANGELOG.md has no content under an "## Unreleased" heading. | ||
| # | ||
| # This repository generates its changelog automatically at release time via | ||
| # craft (`changelogPolicy: auto` in .craft.yml), from the pull requests merged | ||
| # since the previous release. Craft only regenerates the section when it is | ||
| # empty, so a single leftover manual entry under "## Unreleased" suppresses the | ||
| # auto-generation and silently drops every other change from the release notes. | ||
| # | ||
| # Usage: scripts/verify-changelog.sh [path-to-changelog] | ||
| set -euo pipefail | ||
|
|
||
| CHANGELOG="${1:-CHANGELOG.md}" | ||
|
|
||
| if [[ ! -f "$CHANGELOG" ]]; then | ||
| echo "Changelog file not found: $CHANGELOG" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| # Find non-blank lines in the "## Unreleased" section -- everything between the | ||
| # "## Unreleased" heading and the next "## " (h2) heading; "### " sub-headings | ||
| # are not treated as section boundaries. Each match is emitted as | ||
| # "<file-line-number>:<content>" so reported locations point at CHANGELOG.md. | ||
| # | ||
| # craft trims the section body and skips auto-generation whenever it is | ||
| # non-empty (`if (!changeset.body)` after `.trim()`), so ANY non-whitespace | ||
| # content under "## Unreleased" -- a bullet, a stray "### Features" sub-heading, | ||
| # or loose text -- suppresses generation. Match that exactly: fail on any | ||
| # non-blank line. A bare/empty "## Unreleased" heading is fine (craft | ||
| # regenerates it). | ||
| offending="$(awk ' | ||
| /^## / { | ||
| if (in_section) { in_section = 0 } | ||
| if (tolower($0) ~ /^## +unreleased/) { in_section = 1; next } | ||
| } | ||
| in_section && /[^[:space:]]/ { printf "%d:%s\n", NR, $0 } | ||
| ' "$CHANGELOG")" | ||
|
|
||
| if [[ -n "$offending" ]]; then | ||
| echo "::error file=$CHANGELOG::The '## Unreleased' section is not empty." | ||
| echo "" | ||
| echo "This repository generates its changelog automatically at release time" | ||
| echo "(changelogPolicy: auto in .craft.yml). craft only regenerates the" | ||
| echo "'## Unreleased' section when it is empty, so ANY leftover content there" | ||
| echo "(entries or even a bare sub-heading) suppresses generation and causes the" | ||
| echo "rest of the release notes to be dropped." | ||
| echo "" | ||
| echo "Offending line(s) in $CHANGELOG:" | ||
| printf '%s\n' "$offending" | ||
| echo "" | ||
| echo "Please remove them. Your change is added to the changelog automatically," | ||
| echo "based on the PR title / commit message -- or a '### Changelog Entry' section" | ||
| echo "in the PR description if you want a more detailed entry. If it is not" | ||
| echo "user-facing, add the 'skip-changelog' label or write '#skip-changelog' in the" | ||
| echo "PR description." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "OK: '## Unreleased' section is empty." |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.