release.sh: auto-generate notes from git log, prompt to accept/edit/quit

This commit is contained in:
Kyle Bolen
2026-08-02 03:49:14 +00:00
parent 0042f3b6ba
commit b437cbf6e1

View File

@@ -29,16 +29,45 @@ fi
VERSION="$1"
TAG="v${VERSION}"
# Release notes: from argument or prompt
# Release notes: from argument, or auto-generate from git log
if [ $# -ge 2 ]; then
NOTES="$2"
else
echo "Enter release notes (press Enter twice when done):"
NOTES=""
while IFS= read -r line; do
[[ -z "$line" ]] && break
NOTES="${NOTES}${line}\n"
done
# Auto-generate from git log since last tag (or all commits if no tags yet)
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$LAST_TAG" ]; then
RAW_LOG=$(git log "${LAST_TAG}..HEAD" --oneline --no-merges)
LOG_RANGE="since $LAST_TAG"
else
RAW_LOG=$(git log --oneline --no-merges | head -30)
LOG_RANGE="all commits"
fi
echo ""
echo "Auto-generated release notes ($LOG_RANGE):"
echo "──────────────────────────────────────────"
echo "$RAW_LOG"
echo "──────────────────────────────────────────"
echo ""
echo "Accept these as release notes? [y=yes, e=edit, q=quit]"
read -r CHOICE
case "$CHOICE" in
y|Y)
NOTES="$RAW_LOG"
;;
e|E)
TMPFILE=$(mktemp /tmp/photophetch-release-notes.XXXXXX.md)
echo "$RAW_LOG" > "$TMPFILE"
${EDITOR:-nano} "$TMPFILE"
NOTES=$(cat "$TMPFILE")
rm -f "$TMPFILE"
;;
*)
echo "Aborted."
exit 1
;;
esac
fi
# Gitea token