diff options
author | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2021-07-25 15:16:31 -0300 |
commit | 7400e108286a0fceacdac63b125fdc924c2dd50c (patch) | |
tree | 4849176606778477ead8a9ded4c9ff43bf4a8feb /aux/workflow/assert-changelog.sh | |
parent | servers/nixvps/configuration.nix: Serve Git repositories from NGINX, remove G... (diff) | |
download | server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.gz server-7400e108286a0fceacdac63b125fdc924c2dd50c.tar.xz |
aux/: Update
Diffstat (limited to 'aux/workflow/assert-changelog.sh')
-rwxr-xr-x | aux/workflow/assert-changelog.sh | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/aux/workflow/assert-changelog.sh b/aux/workflow/assert-changelog.sh index 8e81f1f..7f9117f 100755 --- a/aux/workflow/assert-changelog.sh +++ b/aux/workflow/assert-changelog.sh @@ -1,14 +1,63 @@ #!/bin/sh set -eu -PROJECT="$1" +TLD="$(cat aux/tld.txt)" +PROJECT_UC= +while getopts 'n:N:' flag; do + case "$flag" in + n) + PROJECT="$OPTARG" + ;; + N) + PROJECT_UC="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) -for VVERSION in $(git tag); do - VERSION="${VVERSION#v}" - DATE="$(git log -1 --format=%cd --date=short "$VVERSION")" +assert_arg() { + if [ -z "$1" ]; then + echo "Missing $2" >&2 + exit 2 + fi +} + +assert_arg "${PROJECT:-}" '-n PROJECT' + +if [ -z "${PROJECT_UC:-}" ]; then + PROJECT_UC="$PROJECT" +fi + +HOMEPAGE_LINK="Changelog for [$PROJECT_UC](https://$TLD/$PROJECT/en/)." + +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 |