From 76e1a0925fde2cbf25b75409cd353e20b9cfef48 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 1 Apr 2023 22:25:46 -0300 Subject: Revamp code under aux/ --- aux/dist.sh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100755 aux/dist.sh (limited to 'aux/dist.sh') diff --git a/aux/dist.sh b/aux/dist.sh new file mode 100755 index 0000000..def68e6 --- /dev/null +++ b/aux/dist.sh @@ -0,0 +1,88 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + EOF +} + +while getopts 'd:V:n:' flag; do + case "$flag" in + d) + DATE="$OPTARG" + ;; + V) + VVERSION="v$OPTARG" + ;; + n) + NAME="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +. aux/lib.sh + +eval "$(assert_arg "${DATE:-}" '-d DATE')" +eval "$(assert_arg "${VVERSION:-}" '-V VERSION')" +eval "$(assert_arg "${NAME:-}" '-n NAME')" + + +if [ "$(git rev-parse --abbrev-ref HEAD)" != 'main' ]; then + echo 'Not on branch "main".' >&2 + exit 1 +fi + +if git show "$VVERSION" 1>/dev/null 2>/dev/null; then + echo "Version '$VVERSION' already exists." >&2 + exit 1 +fi + +if ! printf '%s\n%s\n' "$(git tag)" "$VVERSION" | sort -nct. -k1 -k2 -k3; then + echo 'New tag is not bigger than existing ones.' >&2 + exit 1 +fi + +if [ "$DATE" != "$(git log -1 --format=%ad --date=short HEAD)" ]; then + echo "Date '$DATE' is not up-to-date." >&2 + exit 1 +fi + +if [ "Release $VVERSION" != "$(git log --format=%B -1 HEAD | head -n1)" ]; then + echo "Commit message isn't 'Release $VVERSION'." >&2 + exit 1 +fi + +# FIXME +: make clean check EXTRA_VERSION="$VVERSION" + +if ! (git diff --quiet && git diff --quiet --staged); then + echo 'Dirty repository.' + exit 1 +fi + + +git tag "$VVERSION" +sh aux/workflow/sign-tarballs.sh -n "$NAME" + + +printf 'Publish version? [Y/n]: ' >&2 +read -r publish + +if [ "$publish" = 'n' ]; then + cat <&2 +Now push the tag and the signature before pushing the commit: + +git push origin refs/notes/signatures/tar.gz -o ci.skip --no-verify +git push --tags -o ci.skip --no-verify +git push + +EOF +else + git push origin refs/notes/signatures/tar.gz -o ci.skip --no-verify + git push --tags -o ci.skip --no-verify + git push +fi -- cgit v1.2.3