From 4dcfbd67afca57dbb21109579f825e60312b7f41 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 24 Jun 2021 18:17:26 -0300 Subject: aux/: Update --- aux/assert-shellcheck.sh | 2 +- aux/guix/with-container.sh | 2 +- aux/workflow/TODOs.sh | 43 ++++++++++++++++++++++---- aux/workflow/assert-changelog.sh | 35 ++++++++++++++++++---- aux/workflow/assert-readme.sh | 35 ++++++++++++++++------ aux/workflow/commonmark.sh | 65 +++++++++++++++++++++++++++++++--------- aux/workflow/dist.sh | 61 ++++++++++++++++++++++++++++++++----- aux/workflow/public.sh | 63 ++++++++++++++++++++++++++++++++------ aux/workflow/sign-tarballs.sh | 22 +++++++++++++- 9 files changed, 273 insertions(+), 55 deletions(-) diff --git a/aux/assert-shellcheck.sh b/aux/assert-shellcheck.sh index cc01f3a..1779ea8 100755 --- a/aux/assert-shellcheck.sh +++ b/aux/assert-shellcheck.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -eux +set -eu git ls-files | \ xargs awk 'FNR==1 && /^#!\/bin\/sh$/ { print FILENAME }' | \ diff --git a/aux/guix/with-container.sh b/aux/guix/with-container.sh index b521c82..408fb39 100755 --- a/aux/guix/with-container.sh +++ b/aux/guix/with-container.sh @@ -1,5 +1,5 @@ #!/bin/sh -set -eux +set -eu if [ -z "${1:-}" ]; then guix time-machine --fallback -C aux/guix/pinned-channels.scm -- \ diff --git a/aux/workflow/TODOs.sh b/aux/workflow/TODOs.sh index 160e76f..6c24c3e 100755 --- a/aux/workflow/TODOs.sh +++ b/aux/workflow/TODOs.sh @@ -1,12 +1,43 @@ #!/bin/sh set -eu -mkdir -p public - -PROJECT_UC="$1" -PROJECT="$2" -MAILING_LIST="$3" TLD="$(cat aux/tld.txt)" +PROJECT_UC= +while getopts 'n:N:m:o:' flag; do + case "$flag" in + n) + PROJECT="$OPTARG" + ;; + N) + PROJECT_UC="$OPTARG" + ;; + m) + MAILING_LIST="$OPTARG" + ;; + o) + OUTDIR="$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' +assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST' +assert_arg "${OUTDIR:-}" '-o OUTDIR' + +if [ -z "${PROJECT_UC:-}" ]; then + PROJECT_UC="$PROJECT" +fi TODOS_ADD_REGEX='s/^## (TODO|DOING|WAITING|MEETING|INACTIVE|NEXT|CANCELLED|DONE) (.*) \{#(.*?)\}$/## \1<\/span> \2<\/a>\n
#\3<\/pre>\n/'
 TODOS_CLEANUP_REGEX1='s/( public/TODOs.html
+	> "$OUTDIR/TODOs.html"
diff --git a/aux/workflow/assert-changelog.sh b/aux/workflow/assert-changelog.sh
index 61cd916..11088a8 100755
--- a/aux/workflow/assert-changelog.sh
+++ b/aux/workflow/assert-changelog.sh
@@ -2,10 +2,34 @@
 set -eu
 
 TLD="$(cat aux/tld.txt)"
-PROJECT_UC="$1"
-PROJECT="$2"
-shift
-shift
+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/)."
 
@@ -33,8 +57,7 @@ for VVERSION in $(git tag); do
 done
 
 # "$@" represents a list of tags to be also included in the verification.
-# shellcheck disable=2068
-for VVERSION in $@; do
+for VVERSION in "$@"; do
 	DATE="$(date '+%Y-%m-%d')"
 	assert "$DATE" "$VVERSION"
 done
diff --git a/aux/workflow/assert-readme.sh b/aux/workflow/assert-readme.sh
index 2e5d978..f8a05a4 100755
--- a/aux/workflow/assert-readme.sh
+++ b/aux/workflow/assert-readme.sh
@@ -1,13 +1,31 @@
 #!/bin/sh
 set -eu
 
-mkdir -p public
-
-PROJECT="$1"
-MAILING_LIST="$2"
-shift
-shift
 TLD="$(cat aux/tld.txt)"
+while getopts 'n:m:' flag; do
+	case "$flag" in
+		n)
+			PROJECT="$OPTARG"
+			;;
+		m)
+			MAILING_LIST="$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'
+assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'
 
 EXPECTED="$(mktemp)"
 cat <> "$EXPECTED"
@@ -43,7 +61,7 @@ RELEASES_LIST="$(mktemp)"
 add_release() {
 	DATE="$1"
 	VVERSION="$2"
-	echo "- version [$VVERSION](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz) ([sig](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz.asc)), released in $DATE" >> "$RELEASES_LIST"
+	echo "- [$VVERSION](https://git.euandreh.xyz/$PROJECT/commit/?id=$VVERSION) [$PROJECT-$VVERSION.tar.gz](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz) ([sig](https://git.euandreh.xyz/$PROJECT/snapshot/$PROJECT-$VVERSION.tar.gz.asc)), released in $DATE" >> "$RELEASES_LIST"
 }
 
 for VVERSION in $(git tag); do
@@ -52,8 +70,7 @@ for VVERSION in $(git tag); do
 done
 
 # "$@" represents a list of tags to be also included in the verification.
-# shellcheck disable=2068
-for VVERSION in $@; do
+for VVERSION in "$@"; do
 	if ! git tag | grep -qF "$VVERSION"; then
 		DATE="$(date '+%Y-%m-%d')"
 		add_release "$DATE" "$VVERSION"
diff --git a/aux/workflow/commonmark.sh b/aux/workflow/commonmark.sh
index 6016f51..b196867 100755
--- a/aux/workflow/commonmark.sh
+++ b/aux/workflow/commonmark.sh
@@ -1,20 +1,57 @@
 #!/bin/sh
 set -eu
 
-mkdir -p public
+while getopts 'N:o:r:w:L:' flag; do
+	case "$flag" in
+		N)
+			PROJECT_UC="$OPTARG"
+			;;
+		o)
+			OUTDIR="$OPTARG"
+			;;
+		r)
+			IN_FILE="$OPTARG"
+			;;
+		w)
+			OUT_FILE="$OPTARG"
+			;;
+		L)
+			THE_LANG="$OPTARG"
+			;;
+		*)
+			exit 2
+			;;
+	esac
+done
+shift $((OPTIND - 1))
 
-PROJECT_UC="$1"
-F="$2"
-OUT="${3:-${F%.*}.html}"
+assert_arg() {
+	if [ -z "$1" ]; then
+		echo "Missing $2" >&2
+		exit 2
+	fi
+}
+
+assert_arg "${PROJECT_UC:-}" '-N PROJECT_UC'
+assert_arg "${OUTDIR:-}"     '-o OUTDIR'
+assert_arg "${IN_FILE:-}"    '-i IN_FILE'
+assert_arg "${THE_LANG:-}"   '-L THE_LANG'
+
+if [ -z "${OUT_FILE:-}" ]; then
+	OUT_FILE="${IN_FILE%.md}.html"
+fi
+
+OUT="$OUTDIR/$OUT_FILE"
+mkdir -p "$(dirname "$OUT")"
 
 pandoc \
-	--toc                                    \
-	--highlight-style pygments               \
-	--toc-depth=2                            \
-	-s                                       \
-	--metadata title="$PROJECT_UC - ${F%.*}" \
-	--metadata lang=en                       \
-	-r commonmark                            \
-	-w html                                  \
-	-H aux/workflow/favicon.html             \
-	< "$F" > "public/$OUT"
+	--toc                                           \
+	--highlight-style pygments                      \
+	--toc-depth=2                                   \
+	-s                                              \
+	--metadata title="$PROJECT_UC - ${IN_FILE%%.*}" \
+	--metadata "lang=$THE_LANG"                     \
+	-r commonmark                                   \
+	-w html                                         \
+	-H aux/workflow/favicon.html                    \
+	< "$IN_FILE" > "$OUT"
diff --git a/aux/workflow/dist.sh b/aux/workflow/dist.sh
index ee67f24..69c0173 100755
--- a/aux/workflow/dist.sh
+++ b/aux/workflow/dist.sh
@@ -1,19 +1,54 @@
 #!/bin/sh
 set -eu
 
-DATE="$1"
-VVERSION="v$2"
-PROJECT_UC="$3"
-PROJECT="$4"
-MAILING_LIST="$5"
+PROJECT_UC=
+while getopts 'd:V:n:N:m:' flag; do
+	case "$flag" in
+		d)
+			DATE="$OPTARG"
+			;;
+		V)
+			VVERSION="v$OPTARG"
+			;;
+		n)
+			PROJECT="$OPTARG"
+			;;
+		N)
+			PROJECT_UC="$OPTARG"
+			;;
+		m)
+			MAILING_LIST="$OPTARG"
+			;;
+		*)
+			exit 2
+			;;
+	esac
+done
+shift $((OPTIND - 1))
+
+assert_arg() {
+	if [ -z "$1" ]; then
+		echo "Missing $2" >&2
+		exit 2
+	fi
+}
+
+assert_arg "${DATE:-}"         '-d DATE'
+assert_arg "${VVERSION:-}"     '-V VERSION'
+assert_arg "${PROJECT:-}"      '-n PROJECT'
+assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'
+
+if [ -z "${PROJECT_UC:-}" ]; then
+	PROJECT_UC="$PROJECT"
+fi
 
 if git show "$VVERSION" 1>/dev/null 2>/dev/null; then
 	echo "Version '$VVERSION' already exists." >&2
 	exit 1
 fi
 
-sh aux/workflow/assert-changelog.sh "$PROJECT_UC" "$PROJECT" "$VVERSION"
-sh aux/workflow/assert-readme.sh "$PROJECT" "$MAILING_LIST" "$VVERSION"
+sh aux/workflow/assert-changelog.sh -N "$PROJECT_UC" -n "$PROJECT" "$VVERSION"
+sh aux/workflow/assert-readme.sh -n "$PROJECT" -m "$MAILING_LIST" "$VVERSION"
 
 if [ "$DATE" != "$(git log -1 --format=%cd --date=short HEAD)" ]; then
 	echo "Date '$DATE' is not up-to-date." >&2
@@ -32,4 +67,14 @@ fi
 
 git tag "$VVERSION"
 
-sh aux/workflow/sign-tarballs.sh "$PROJECT"
+sh aux/workflow/sign-tarballs.sh -n "$PROJECT"
+
+
+cat <&2
+Now push the tag and the signature before pushing the commit:
+
+git push origin refs/notes/signatures/tar.gz -o skip-ci --no-verify
+git push --tags -o skip-ci --no-verify
+git push
+
+EOF
diff --git a/aux/workflow/public.sh b/aux/workflow/public.sh
index 8ecb855..be32ac1 100755
--- a/aux/workflow/public.sh
+++ b/aux/workflow/public.sh
@@ -1,17 +1,62 @@
 #!/bin/sh
 set -eu
 
-PROJECT_UC="$1"
-PROJECT="$2"
-MAILING_LIST="$3"
+PROJECT_UC=
+while getopts 'n:N:m:o:l:' flag; do
+	case "$flag" in
+		n)
+			PROJECT="$OPTARG"
+			;;
+		N)
+			PROJECT_UC="$OPTARG"
+			;;
+		m)
+			MAILING_LIST="$OPTARG"
+			;;
+		o)
+			OUTDIR="$OPTARG"
+			;;
+		l)
+			LANGS="$OPTARG"
+			;;
+		*)
+			exit 2
+			;;
+	esac
+done
+shift $((OPTIND - 1))
 
-sh aux/workflow/TODOs.sh  "$PROJECT_UC" "$PROJECT" "$MAILING_LIST"
-sh aux/workflow/commonmark.sh "$PROJECT" README.md index.html ||:
+assert_arg() {
+	if [ -z "$1" ]; then
+		echo "Missing $2" >&2
+		exit 2
+	fi
+}
 
-if [ -f CHANGELOG.md ]; then
-	sh aux/workflow/commonmark.sh "$PROJECT" CHANGELOG.md
+assert_arg "${PROJECT:-}"      '-n PROJECT'
+assert_arg "${MAILING_LIST:-}" '-m MAILING_LIST'
+assert_arg "${OUTDIR:-}"       '-o OUTDIR'
+
+if [ -z "${PROJECT_UC:-}" ]; then
+	PROJECT_UC="$PROJECT"
 fi
 
-sh aux/ci/report.sh "$PROJECT"
+mkdir -p "$OUTDIR"
+
+sh aux/workflow/TODOs.sh -N "$PROJECT_UC" -n "$PROJECT" -m "$MAILING_LIST" -o "$OUTDIR"
+
+sh aux/workflow/commonmark.sh -N "$PROJECT" -o "$OUTDIR" -r README.md -w index.html -Len
+if [ -f CHANGELOG.md ]; then
+	sh aux/workflow/commonmark.sh -N "$PROJECT" -o "$OUTDIR" -r CHANGELOG.md -Len
+fi
+if [ -n "${LANGS:-}" ]; then
+	for lang in $LANGS; do
+		sh aux/workflow/commonmark.sh -N "$PROJECT" -o "$OUTDIR" -r "README.$lang.md" -w "$lang/index.html" -L "$lang"
+		if [ -f CHANGELOG.md ]; then
+			sh aux/workflow/commonmark.sh -N "$PROJECT" -o "$OUTDIR" -r "CHANGELOG.$lang.md" -w "$lang/CHANGELOG.html" -L "$lang"
+		fi
+	done
+fi
 
-cp aux/workflow/favicon.* public/
+sh aux/ci/report.sh -n "$PROJECT" -o "$OUTDIR"
+cp aux/workflow/favicon.svg aux/workflow/favicon.png "$OUTDIR"
diff --git a/aux/workflow/sign-tarballs.sh b/aux/workflow/sign-tarballs.sh
index 8de6ac4..168d38d 100755
--- a/aux/workflow/sign-tarballs.sh
+++ b/aux/workflow/sign-tarballs.sh
@@ -1,7 +1,27 @@
 #!/bin/sh
 set -eu
 
-PROJECT="$1"
+while getopts 'n:' flag; do
+	case "$flag" in
+		n)
+			PROJECT="$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'
+
 
 SIGNATURES="$(git notes --ref=refs/notes/signatures/tar.gz list | cut -d\  -f2)"
 for tag in $(git tag); do
-- 
cgit v1.2.3