Skip to content

Merge 5.0.0 into 5.0.1 #115

Merge 5.0.0 into 5.0.1

Merge 5.0.0 into 5.0.1 #115

name: 5.x Changelog check
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled]
jobs:
changelog_check:
runs-on: ubuntu-24.04
if: ${{ github.event_name == 'pull_request' && !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name, 'no-changelog') }}
permissions:
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Validate CHANGELOG.md changes
env:
BASE_REF: ${{ github.base_ref }}
run: |
UPDATED="✅" FORMAT="—" INVALID=""
ADDED=$(git diff -U0 "origin/${BASE_REF}...HEAD" -- CHANGELOG.md | grep -E '^\+[^+]' | sed 's/^+//' || true)
if [ -z "$ADDED" ]; then
UPDATED="❌"
echo "::error::CHANGELOG.md was not updated with new entries. Add one or add the 'no-changelog' label to skip this check."
else
FORMAT="✅"
TABLE_ENTRY_REGEX='^\| \[#[0-9]+\]\(https://github\.com/[^)]+/(issues|pull)/[0-9]+\) \| .+ \|$'
TABLE_HEADER_REGEX='^\| Issue \| Comment \|$|^\| - \| - \|$'
PRIOR_VERSION_REGEX='^- \[v?[0-9]+\.[0-9]+\.[0-9]+\]\(https://github\.com/[^)]+/blob/[^)]+/CHANGELOG\.md\)$|^- \[\]\(\)$'
INVALID=$(echo "$ADDED" | grep -E '^(\||-)' | grep -vx -- '- None' | grep -vE "$TABLE_HEADER_REGEX" | grep -vE "$TABLE_ENTRY_REGEX" | grep -vE "$PRIOR_VERSION_REGEX" || true)
if [ -n "$INVALID" ]; then
FORMAT="❌"
echo "::error::Invalid CHANGELOG.md entries. Offending lines:"
echo "$INVALID"
echo "::error::Expected formats:"
echo "::error:: - Table entry: '| [#123](https://github.com/<org>/<repo>/issues/123) | Description |'"
echo "::error:: - Prior versions entry: '- [vX.Y.Z](https://github.com/<org>/<repo>/blob/vX.Y.Z/CHANGELOG.md)'"
echo "::error:: - Prior versions placeholder (no prior version): '- []()'"
fi
fi
{
echo "## Changelog check"
echo ""
echo "| Check | Result |"
echo "|---|---|"
echo "| CHANGELOG.md has new entries | $UPDATED |"
echo "| Entry format | $FORMAT |"
if [ -n "$INVALID" ]; then
echo ""
echo "Offending lines:"
echo '```'
echo "$INVALID"
echo '```'
fi
} >> "$GITHUB_STEP_SUMMARY"
if [ "$UPDATED" != "✅" ] || [ "$FORMAT" != "✅" ]; then
exit 1
fi
echo "CHANGELOG.md update is valid."