diff --git a/hack/tfw.sh b/hack/tfw.sh index 55e9ac1..f683a5f 100755 --- a/hack/tfw.sh +++ b/hack/tfw.sh @@ -39,7 +39,9 @@ release_baseimage() read -p "Tag and push new TFW version \"${TAG}\"? [y/N]" -r && echo if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]] then - TAG="$TAG" force_push_tag + description="" + prompt_for_tag_description # This command overwrites $description + TAG="$TAG" DESCRIPTION="$description" force_push_tag fi } @@ -54,11 +56,33 @@ check_drone_releasename() fi } +prompt_for_tag_description() +{ + editor="$(git config --global core.editor)" + tempfile="$(mktemp)" + + printf "\n\n" >> "$tempfile" + echo "# Please enter the description for this release." >> "$tempfile" + echo "# Lines starting with '#' will be ignored." >> "$tempfile" + echo "# An empty description aborts the release." >> "$tempfile" + + $editor "$tempfile" + sed -i -e 's/#.*$//' -e '/^$/d' "$tempfile" + sed -i 's/\n/ /g' "$tempfile" + if [[ ! -s "$tempfile" ]]; then + echo "Aborting release due to empty description." + exit 1 + fi + + description="$(tr '\n' ' ' < "$tempfile")" + rm "$tempfile" +} + force_push_tag() { git tag -d "$TAG" > /dev/null 2>&1 || : git push --delete origin "$TAG" > /dev/null 2>&1 || : - git tag -s -m "TFW version $TAG released at $(date '+%H:%M:%S %Y-%m-%d')" "$TAG" + git tag -s -m "$DESCRIPTION" "$TAG" git push origin "$TAG" }