-
-
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 1 commit
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
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/usr/bin/env bash | ||
| # | ||
| # Verifies that CHANGELOG.md contains no manually-added entries 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 | ||
|
jamescrosswell marked this conversation as resolved.
Outdated
|
||
| # empty, so a single leftover manual entry under "## Unreleased" suppresses the | ||
| # auto-generation and silently drops every other change from the release notes. | ||
| # (This is what broke the 6.7.0 release, which shipped with a single entry.) | ||
|
jamescrosswell marked this conversation as resolved.
Outdated
|
||
| # | ||
| # 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 | ||
|
|
||
| # Extract the body of the "## Unreleased" section: everything between the | ||
| # "## Unreleased" heading and the next "## " (h2) heading. "### " sub-headings | ||
| # are not treated as section boundaries. | ||
| unreleased_body="$(awk ' | ||
| /^## / { | ||
| if (in_section) exit | ||
| if (tolower($0) ~ /^## +unreleased/) { in_section = 1; next } | ||
| } | ||
| in_section { print } | ||
| ' "$CHANGELOG")" | ||
|
|
||
| # A manual changelog entry is a bullet line ("- ..." or "* ..."). This | ||
| # deliberately ignores an empty "## Unreleased" heading and blank/sub-heading | ||
| # lines, so only real entries fail the check. | ||
| entry_re='^[[:space:]]*[-*][[:space:]]+[^[:space:]]' | ||
|
|
||
| if printf '%s\n' "$unreleased_body" | grep -Eq "$entry_re"; then | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| echo "::error file=$CHANGELOG::Manual changelog entries found under '## Unreleased'." | ||
| echo "" | ||
| echo "This repository generates its changelog automatically at release time" | ||
| echo "(changelogPolicy: auto in .craft.yml). A manual entry under '## Unreleased'" | ||
| echo "suppresses that generation and causes other changes to be dropped from the" | ||
| echo "release notes." | ||
| echo "" | ||
| echo "Offending line(s):" | ||
| printf '%s\n' "$unreleased_body" | grep -En "$entry_re" || true | ||
|
jamescrosswell marked this conversation as resolved.
Outdated
|
||
| echo "" | ||
| echo "Please remove them. Your change is added to the changelog automatically," | ||
| echo "based on the PR title / commit message. If it is not user-facing, add the" | ||
|
jamescrosswell marked this conversation as resolved.
Outdated
|
||
| echo "'skip-changelog' label or write '#skip-changelog' in the PR description." | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "OK: no manual '## Unreleased' changelog entries." | ||
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.