@@ -4,6 +4,7 @@ permissions:
44 pull-requests : read
55on :
66 pull_request :
7+ types : [opened, synchronize, reopened, labeled, unlabeled]
78 branches-ignore :
89 - " v[0-9]+.[0-9]+.[0-9]+.[0-9]+"
910 - release
@@ -166,6 +167,64 @@ jobs:
166167 body-path : doc-check-results.md
167168 edit-mode : replace
168169
170+ changelog-check :
171+ needs : changed-crates
172+ if : |
173+ needs.changed-crates.outputs.crates_count > 0 &&
174+ !contains(github.event.pull_request.labels.*.name, 'skip-changelog-check')
175+ runs-on : ubuntu-latest
176+ steps :
177+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
178+ with :
179+ fetch-depth : 0 # Need full history for git diff
180+ - name : Check for CHANGELOG.md changes in publishable crates
181+ run : |
182+ # Get the base ref for comparison
183+ BASE_REF='${{ needs.changed-crates.outputs.base_ref }}'
184+
185+ # Get the list of changed crates
186+ CRATES='${{ needs.changed-crates.outputs.crates }}'
187+
188+ FAILED=0
189+ MODIFIED_CHANGELOGS=()
190+
191+ while read -r crate; do
192+ NAME=$(echo "$crate" | jq -r '.name')
193+ CRATE_PATH=$(echo "$crate" | jq -r '.path')
194+ CHANGELOG_PATH="$CRATE_PATH/CHANGELOG.md"
195+
196+ # Check if CHANGELOG.md exists
197+ if [[ ! -f "$CHANGELOG_PATH" ]]; then
198+ # This shouldn't happen, skipping for now.
199+ continue
200+ fi
201+
202+ # Check if CHANGELOG.md has been modified in this PR
203+ if git diff --name-only "$BASE_REF" HEAD | grep -q "^$CHANGELOG_PATH$"; then
204+ MODIFIED_CHANGELOGS+=("$NAME ($CHANGELOG_PATH)")
205+ FAILED=1
206+ fi
207+ done < <(echo "$CRATES" | jq -c '.[]')
208+
209+ if [[ $FAILED -eq 1 ]]; then
210+ echo ""
211+ echo "=========================================="
212+ echo "ERROR: CHANGELOG.md files modified in publishable crates"
213+ echo "=========================================="
214+ echo ""
215+ echo "The following publishable crates have CHANGELOG.md changes:"
216+ for changelog in "${MODIFIED_CHANGELOGS[@]}"; do
217+ echo " - $changelog"
218+ done
219+ echo ""
220+ echo "CHANGELOG.md files should only be updated during the release process."
221+ echo "Please revert the CHANGELOG.md changes from this PR."
222+ exit 1
223+ fi
224+
225+ echo ""
226+ echo "No CHANGELOG.md changes detected in publishable crates"
227+
169228 dependency-check :
170229 needs : changed-crates
171230 if : needs.changed-crates.outputs.crates_count > 0
0 commit comments