fix: clean up release notes for end users
Build and Release / build-and-release (push) Has been cancelled
Build and Release / build-and-release (push) Has been cancelled
This commit is contained in:
@@ -2,12 +2,10 @@
|
|||||||
#
|
#
|
||||||
# Generate Markdown release notes from conventional commits.
|
# Generate Markdown release notes from conventional commits.
|
||||||
# Usage: ./scripts/generate-release-notes.sh <tag> [prev-ref]
|
# Usage: ./scripts/generate-release-notes.sh <tag> [prev-ref]
|
||||||
# e.g. ./scripts/generate-release-notes.sh v0.7.0
|
|
||||||
# e.g. ./scripts/generate-release-notes.sh v0.7.0 abc123f
|
|
||||||
#
|
#
|
||||||
|
# Skips version bumps, CI-only changes, and other noise.
|
||||||
# If prev-ref is not provided, tries git describe to find previous tag.
|
# If prev-ref is not provided, tries git describe to find previous tag.
|
||||||
# If no previous ref is found, includes all commits up to HEAD.
|
# If no previous ref is found, includes all commits up to HEAD.
|
||||||
# Uses HEAD as the endpoint (tag may not exist in git yet).
|
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
@@ -21,32 +19,32 @@ fi
|
|||||||
|
|
||||||
if [ -n "$PREV_REF" ]; then
|
if [ -n "$PREV_REF" ]; then
|
||||||
RANGE="${PREV_REF}..HEAD"
|
RANGE="${PREV_REF}..HEAD"
|
||||||
COMPARE_TEXT="**Full changelog**: \`${PREV_REF}...${TAG}\`"
|
|
||||||
else
|
else
|
||||||
RANGE="HEAD"
|
RANGE="HEAD"
|
||||||
COMPARE_TEXT="**Initial release**"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect commits into temp files by category
|
# Collect commits into temp files by category
|
||||||
TMPDIR_NOTES=$(mktemp -d)
|
TMPDIR_NOTES=$(mktemp -d)
|
||||||
trap 'rm -rf "$TMPDIR_NOTES"' EXIT
|
trap 'rm -rf "$TMPDIR_NOTES"' EXIT
|
||||||
|
|
||||||
for prefix in feat fix refactor perf docs test chore other; do
|
for prefix in feat fix refactor perf other; do
|
||||||
: > "${TMPDIR_NOTES}/${prefix}"
|
: > "${TMPDIR_NOTES}/${prefix}"
|
||||||
done
|
done
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
[ -z "$line" ] && continue
|
[ -z "$line" ] && continue
|
||||||
|
|
||||||
|
# Skip version bump commits (e.g. "v0.6.1", "v0.6.2 — description")
|
||||||
|
[[ "$line" =~ ^v[0-9] ]] && continue
|
||||||
|
|
||||||
|
# Skip chore/docs/test/ci commits — not user-facing
|
||||||
|
[[ "$line" =~ ^(chore|docs|test|ci)(\(.*\))?: ]] && continue
|
||||||
|
|
||||||
MATCHED=false
|
MATCHED=false
|
||||||
for prefix in feat fix refactor perf docs test chore; do
|
for prefix in feat fix refactor perf; do
|
||||||
if [[ "$line" =~ ^${prefix}(\(.*\))?:\ (.+)$ ]]; then
|
if [[ "$line" =~ ^${prefix}(\(.*\))?:\ (.+)$ ]]; then
|
||||||
SCOPE="${BASH_REMATCH[1]}"
|
|
||||||
MSG="${BASH_REMATCH[2]}"
|
MSG="${BASH_REMATCH[2]}"
|
||||||
if [ -n "$SCOPE" ]; then
|
echo "- ${MSG}" >> "${TMPDIR_NOTES}/${prefix}"
|
||||||
echo "- **${SCOPE}**: ${MSG}" >> "${TMPDIR_NOTES}/${prefix}"
|
|
||||||
else
|
|
||||||
echo "- ${MSG}" >> "${TMPDIR_NOTES}/${prefix}"
|
|
||||||
fi
|
|
||||||
MATCHED=true
|
MATCHED=true
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@@ -59,36 +57,34 @@ done < <(git log --format="%s" "$RANGE" 2>/dev/null)
|
|||||||
# Section display names
|
# Section display names
|
||||||
section_title() {
|
section_title() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
feat) echo "Features" ;;
|
feat) echo "## New" ;;
|
||||||
fix) echo "Bug Fixes" ;;
|
fix) echo "## Fixes" ;;
|
||||||
refactor) echo "Refactoring" ;;
|
refactor) echo "## Improvements" ;;
|
||||||
perf) echo "Performance" ;;
|
perf) echo "## Performance" ;;
|
||||||
docs) echo "Documentation" ;;
|
|
||||||
test) echo "Tests" ;;
|
|
||||||
chore) echo "Chores" ;;
|
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# Build output
|
# Build output — only user-facing sections
|
||||||
echo "# KCC ${TAG}"
|
HAS_CONTENT=false
|
||||||
echo ""
|
|
||||||
|
|
||||||
for prefix in feat fix refactor perf docs test chore; do
|
for prefix in feat fix refactor perf; do
|
||||||
if [ -s "${TMPDIR_NOTES}/${prefix}" ]; then
|
if [ -s "${TMPDIR_NOTES}/${prefix}" ]; then
|
||||||
echo "## $(section_title "$prefix")"
|
section_title "$prefix"
|
||||||
echo ""
|
echo ""
|
||||||
cat "${TMPDIR_NOTES}/${prefix}"
|
cat "${TMPDIR_NOTES}/${prefix}"
|
||||||
echo ""
|
echo ""
|
||||||
|
HAS_CONTENT=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -s "${TMPDIR_NOTES}/other" ]; then
|
if [ -s "${TMPDIR_NOTES}/other" ]; then
|
||||||
echo "## Other Changes"
|
echo "## Other"
|
||||||
echo ""
|
echo ""
|
||||||
cat "${TMPDIR_NOTES}/other"
|
cat "${TMPDIR_NOTES}/other"
|
||||||
echo ""
|
echo ""
|
||||||
|
HAS_CONTENT=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "---"
|
if [ "$HAS_CONTENT" = false ]; then
|
||||||
echo ""
|
echo "Bug fixes and improvements."
|
||||||
echo "${COMPARE_TEXT}"
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user