2017-02-13 14:01:54 -05:00
|
|
|
#!/usr/bin/env bash
|
2016-12-07 07:23:03 -05:00
|
|
|
|
|
|
|
changelogFile=${1:-CHANGELOG.md}
|
|
|
|
|
2019-01-09 20:23:38 -05:00
|
|
|
if [ ! -r "$changelogFile" ]; then
|
2016-12-07 07:23:03 -05:00
|
|
|
echo "Unable to read file $changelogFile" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
changelogWellFormed=1
|
|
|
|
|
|
|
|
# e.g. "## 1.12.3 (2016-10-26)"
|
2017-02-22 20:38:37 -05:00
|
|
|
VER_LINE_REGEX='^## [0-9]+\.[0-9]+\.[0-9]+(-ce)? \([0-9]+-[0-9]+-[0-9]+\)$'
|
2016-12-07 07:23:03 -05:00
|
|
|
while read -r line; do
|
|
|
|
if ! [[ "$line" =~ $VER_LINE_REGEX ]]; then
|
|
|
|
echo "Malformed changelog $changelogFile line \"$line\"" >&2
|
|
|
|
changelogWellFormed=0
|
|
|
|
fi
|
|
|
|
done < <(grep '^## ' $changelogFile)
|
|
|
|
|
|
|
|
if [[ "$changelogWellFormed" == "1" ]]; then
|
|
|
|
echo "Congratulations! Changelog $changelogFile is well-formed."
|
|
|
|
else
|
|
|
|
exit 2
|
|
|
|
fi
|