From a99db0d7285b77241d3e8d07c2ad32a706e77cf5 Mon Sep 17 00:00:00 2001 From: blankll Date: Sat, 3 Oct 2026 14:43:00 +0800 Subject: [PATCH] chore(release): user-facing release notes rendering MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rework build-release-notes.sh so the published GitHub release reads as product release notes instead of a commit log dump: - changelog sections get emoji headings (Added -> ✨ Added, Fixed -> 🐛 Fixed, ...); entry language is untouched — each repo keeps its own - '(#N)' references linkify to the originating GitHub PR (repo URL derived from the origin remote, https and ssh both supported) - the contributors section is omitted for solo-author releases - the full commit list moves into a collapsed
block - a new optional .github/release-notes-footer.md is appended verbatim — the per-repo spot for commercial tails (mirrors, upgrade guidance) - RELEASE_NOTES_VERSION env override for local testing (CI unaffected) Verified against the v0.8.7 changelog data: emoji headings, PR linkification and the collapsed history all render correctly. --- scripts/build-release-notes.sh | 64 ++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/scripts/build-release-notes.sh b/scripts/build-release-notes.sh index 3505b641..f0f4d9e1 100755 --- a/scripts/build-release-notes.sh +++ b/scripts/build-release-notes.sh @@ -1,8 +1,22 @@ #!/bin/bash -e -VERSION=$(node -p "require('./package.json').version") +# Compose the GitHub release body from CHANGELOG.md + git metadata. +# +# Presentation conventions (shared shape across geek-fun repos): +# - Changelog sections get emoji headings (### Added -> ### ✨ Added) +# - "(#N)" references are linkified to the originating GitHub PR +# - Contributors section is omitted when only one author contributed +# - The full commit list is kept but collapsed inside
+# - .github/release-notes-footer.md (if present) is appended verbatim — +# per-repo commercial tail: mirrors, upgrade guidance, support links. + +VERSION=${RELEASE_NOTES_VERSION:-$(node -p "require('./package.json').version")} PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") +# Derive the GitHub repo URL from the origin remote (works for https/ssh). +REMOTE_URL=$(git remote get-url origin 2>/dev/null || echo "") +REPO_URL=$(echo "$REMOTE_URL" | sed -E 's#^git@github\.com:#https://github.com/#; s#^https?://(www\.)?github\.com/#https://github.com/#; s#\.git$##') + CHANGELOG=$(awk -v version="$VERSION" ' $0 ~ "^## \\[" version "\\]" { found=1; next } found && /^## \[/ { exit } @@ -14,14 +28,33 @@ if [ -z "$CHANGELOG" ]; then CHANGELOG="See the assets to download this version and install." fi +# Decorate known Keep-a-Changelog sections with emoji headings and turn +# "(#N)" into PR links. Section decoration is language-neutral: whatever +# language the repo writes entries in is preserved. +CHANGELOG=$(echo "$CHANGELOG" \ + | sed -E \ + -e 's/^### Added$/### ✨ Added/' \ + -e 's/^### Fixed$/### 🐛 Fixed/' \ + -e 's/^### Changed$/### 🔧 Changed/' \ + -e 's/^### Security$/### 🔒 Security/' \ + -e 's/^### Deprecated$/### ⚠️ Deprecated/' \ + -e 's/^### Removed$/### 🗑 Removed/') +if [ -n "$REPO_URL" ]; then + CHANGELOG=$(echo "$CHANGELOG" | sed -E "s|\(#([0-9]+)\)|([#\1](${REPO_URL}/pull/\1))|g") +fi + if [ -n "$PREVIOUS_TAG" ]; then - CONTRIBUTORS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"%an" 2>/dev/null | sort | uniq) + AUTHORS=$(git log ${PREVIOUS_TAG}..HEAD --pretty=format:"%an" 2>/dev/null | sort -u) + AUTHOR_COUNT=$(echo "$AUTHORS" | grep -c . || true) else - CONTRIBUTORS=$(git log HEAD --pretty=format:"%an" 2>/dev/null | sort | uniq) + AUTHORS=$(git log HEAD --pretty=format:"%an" 2>/dev/null | sort -u) + AUTHOR_COUNT=$(echo "$AUTHORS" | grep -c . || true) fi CONTRIBUTORS_MD="" -if [ -n "$CONTRIBUTORS" ]; then +# Community acknowledgment only makes sense with outside contributors — +# a solo-author release reads as noise, so skip it entirely. +if [ "$AUTHOR_COUNT" -gt 1 ]; then while IFS= read -r name; do [ -z "$name" ] && continue if [ -n "$PREVIOUS_TAG" ]; then @@ -31,7 +64,7 @@ if [ -n "$CONTRIBUTORS" ]; then fi SUFFIX=""; [ "$COUNT" -gt 1 ] && SUFFIX="s" CONTRIBUTORS_MD="${CONTRIBUTORS_MD}- **${name}** (${COUNT} commit${SUFFIX})\n" - done <<< "$CONTRIBUTORS" + done <<< "$AUTHORS" fi if [ -n "$PREVIOUS_TAG" ]; then @@ -45,24 +78,33 @@ fi { echo "$CHANGELOG" echo "" - echo "## 👥 Contributors" - echo "" - echo -e "$CONTRIBUTORS_MD" + if [ -n "$CONTRIBUTORS_MD" ]; then + echo "## 👥 Contributors" + echo "" + echo -e "$CONTRIBUTORS_MD" + echo "" + fi echo "---" echo "" - echo "## 📋 Full Commit History" + echo "
" + echo "📋 Full commit history" echo "" echo "$RANGE_LABEL" echo "" echo "$COMMITS" echo "" + echo "
" echo "" echo "---" echo "" echo "## 📦 Downloads" echo "" echo "See the assets below to download this version and install for your platform:" - echo "- **macOS**: Universal binary (Intel & Apple Silicon)" + echo "- **macOS**: Apple Silicon & Intel" echo "- **Windows**: x64 installer" - echo "- **Linux**: x64 AppImage/deb" + echo "- **Linux**: AppImage / deb" + if [ -f .github/release-notes-footer.md ]; then + echo "" + cat .github/release-notes-footer.md + fi } > release-notes.md