aboutsummaryrefslogtreecommitdiff
path: root/aux/workflow/assert-changelog.sh
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2022-01-18 11:40:47 -0300
committerEuAndreh <eu@euandre.org>2022-01-18 14:02:59 -0300
commit47bfd2ed8c3219e79f8974a8fc2ac9265ed91bd2 (patch)
tree3d162596d874b4f775da12c843ad3918b593f713 /aux/workflow/assert-changelog.sh
parentInitial empty commit (diff)
downloadtd-47bfd2ed8c3219e79f8974a8fc2ac9265ed91bd2.tar.gz
td-47bfd2ed8c3219e79f8974a8fc2ac9265ed91bd2.tar.xz
First commit, now with a clean history
Diffstat (limited to '')
-rwxr-xr-xaux/workflow/assert-changelog.sh66
1 files changed, 66 insertions, 0 deletions
diff --git a/aux/workflow/assert-changelog.sh b/aux/workflow/assert-changelog.sh
new file mode 100755
index 0000000..c58a600
--- /dev/null
+++ b/aux/workflow/assert-changelog.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+set -eu
+
+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))
+
+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="$(printf \
+ '# [%s](https://euandreh.xyz/%s.git/commit/?id=%s) - %s' \
+ "$VERSION" "$PROJECT" "$VVERSION" "$DATE")"
+ if ! grep -qF "$CHANGELOG_ENTRY" CHANGELOG.md; then
+ echo "Missing '$CHANGELOG_ENTRY' entry from CHANGELOG.md" >&2
+ exit 1
+ fi
+}
+
+if [ -e .git ]; then
+ for VVERSION in $(git tag); do
+ DATE="$(git log -1 --format=%cd --date=short "$VVERSION")"
+ assert "$DATE" "$VVERSION"
+ done
+fi
+
+# "$@" 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