From b437cbf6e100f4c9295441827c3b5d0f92cd2e4b Mon Sep 17 00:00:00 2001 From: Kyle Bolen Date: Sun, 2 Aug 2026 03:49:14 +0000 Subject: [PATCH] release.sh: auto-generate notes from git log, prompt to accept/edit/quit --- release.sh | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/release.sh b/release.sh index b4d9af9..07c99cc 100755 --- a/release.sh +++ b/release.sh @@ -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