Skip to content

Commit eb5ebf1

Browse files
committed
tools: add additional version checks to changelog validation
Signed-off-by: Dhwani Serai <dhwanise@amazon.com>
1 parent 6b5586b commit eb5ebf1

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

tools/validate-changelog.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,22 @@
44
# this should be sufficient to validate the CHANGELOG for our CI, provided that
55
# every new tag has a corresponding CHANGELOG update, as we always parse the
66
# CHANGELOG between two headers with a tagged version.
7-
if diff <(grep -ne '^# ' CHANGELOG.md) <(grep -ne '^# v[0-9]\+\.[0-9]\+\.[0-9]\+' CHANGELOG.md); then
8-
echo "CHANGELOG validation PASSED!"
9-
else
7+
if ! diff <(grep -ne '^# ' CHANGELOG.md) <(grep -ne '^# v[0-9]\+\.[0-9]\+\.[0-9]\+' CHANGELOG.md); then
108
echo "CHANGELOG validation FAILED! Headers must match the regex '^# v[0-9]\+\.[0-9]\+\.[0-9]\+.'"
119
exit 1
1210
fi
11+
12+
# check that all versions are unique
13+
versions=$(grep -o '^# v[0-9]\+\.[0-9]\+\.[0-9]\+' CHANGELOG.md)
14+
if [[ $(echo "${versions}" | sort | uniq -d | wc -l) -gt 0 ]]; then
15+
echo "CHANGELOG validation FAILED! Duplicate versions found."
16+
exit 1
17+
fi
18+
19+
# check that versions are in descending order
20+
if ! echo "${versions}" | sort -V -r | diff - <(echo "${versions}"); then
21+
echo "CHANGELOG validation FAILED! Versions must be in descending order."
22+
exit 1
23+
else
24+
echo "CHANGELOG validation PASSED!"
25+
fi

0 commit comments

Comments
 (0)