github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/hack/validate/changelog-well-formed (about)

     1  #!/usr/bin/env bash
     2  
     3  changelogFile=${1:-CHANGELOG.md}
     4  
     5  if [ ! -r "$changelogFile" ]; then
     6  	echo "Unable to read file $changelogFile" >&2
     7  	exit 1
     8  fi
     9  
    10  changelogWellFormed=1
    11  
    12  # e.g. "## 1.12.3 (2016-10-26)"
    13  VER_LINE_REGEX='^## [0-9]+\.[0-9]+\.[0-9]+(-ce)? \([0-9]+-[0-9]+-[0-9]+\)$'
    14  while read -r line; do
    15  	if ! [[ "$line" =~ $VER_LINE_REGEX ]]; then
    16  		echo "Malformed changelog $changelogFile line \"$line\"" >&2
    17  		changelogWellFormed=0
    18  	fi
    19  done < <(grep '^## ' $changelogFile)
    20  
    21  if [[ "$changelogWellFormed" == "1" ]]; then
    22  	echo "Congratulations!  Changelog $changelogFile is well-formed."
    23  else
    24  	exit 2
    25  fi