aboutsummaryrefslogblamecommitdiff
path: root/aux/workflow/assert-changelog.sh
blob: e2cd926138428fd5ad180f33a0f83736165368f0 (plain) (tree)
1
2
3
4
5
6
7
8
9


         
                        


               
     
 
                                                                    










                                                            
                                                                                                      
 



                                                                             







                                                                         
                        

                                  
    
#!/bin/sh
set -eu

TLD="$(cat aux/tld.txt)"
PROJECT_UC="$1"
PROJECT="$2"
shift
shift

HOMEPAGE_LINK="Changelog for [$PROJECT_UC](https://$TLD/$PROJECT/)."

if ! grep -qF "$HOMEPAGE_LINK" CHANGELOG.md; then
	echo "Missing link to homepage in CHANGELOG.md:" >&2
	echo "$HOMEPAGE_LINK"
	exit 1
fi

assert() {
	DATE="$1"
	VVERSION="$2"
	VERSION="${2#v}"
	CHANGELOG_ENTRY="# [$VERSION](https://git.euandreh.xyz/$PROJECT/commit/?id=$VVERSION) - $DATE"

	if ! grep -qF "$CHANGELOG_ENTRY" CHANGELOG.md; then
		echo "Missing '$CHANGELOG_ENTRY' entry from CHANGELOG.md" >&2
		exit 1
	fi
}

for VVERSION in $(git tag); do
	DATE="$(git log -1 --format=%cd --date=short "$VVERSION")"
	assert "$DATE" "$VVERSION"
done

# "$@" represents a list of tags to be also included in the verification.
for VVERSION in "$@"; do
	DATE="$(date '+%Y-%m-%d')"
	assert "$DATE" "$VVERSION"
done