@@ -90,50 +90,49 @@ jobs:
9090 id : changelog
9191 shell : bash
9292 run : |
93- TAG_NAME="${{ github.ref_name }}"
93+ set -e
94+ TAG_NAME="${GITHUB_REF_NAME}"
9495 PREV_TAG=$(git tag --sort=-creatordate | grep -v "^$TAG_NAME$" | head -1)
9596
9697 if [ -z "$PREV_TAG" ]; then
97- RANGE="HEAD"
98+ COMMITS=($(git log --pretty=format:"%s %h" --no-merges))
9899 else
99- RANGE= "$PREV_TAG..HEAD"
100+ COMMITS=($(git log "$PREV_TAG..HEAD" --pretty=format:"%s %h" --no-merges))
100101 fi
101102
102103 echo "## Changes" > /tmp/changelog.md
103104 echo "" >> /tmp/changelog.md
104105
105- git log "$RANGE" --pretty=format:"%s %h" --no-merges | while IFS= read -r line; do
106- message="${line% *}"
107- hash="${line##* }"
108-
109- category=""
110- if echo "$message" | grep -qE '^feat[(:]'; then
111- category="🚀 feat"
112- elif echo "$message" | grep -qE '^fix[(:]'; then
113- category="🐛 fix"
114- elif echo "$message" | grep -qE '^perf[(:]'; then
115- category="⚡ perf"
116- elif echo "$message" | grep -qE '^refactor[(:]'; then
117- category="♻️ refactor"
118- elif echo "$message" | grep -qE '^test[(:]'; then
119- category="✅ test"
120- elif echo "$message" | grep -qE '^docs[(:]'; then
121- category="📝 docs"
122- elif echo "$message" | grep -qE '^chore[(:]'; then
123- category="🔧 chore"
124- elif echo "$message" | grep -qE '^ci[(:]'; then
125- category="👷 ci"
126- else
127- category="📦 other"
128- fi
129-
130- clean_msg=$(echo "$message" | sed -E 's/^[a-z]+(\([^)]*\))?: ?//')
131- echo "- **$category**: $clean_msg (\`$hash\`)" >> /tmp/changelog.md
132- done
133-
134- echo "body<<EOF" >> "$GITHUB_OUTPUT"
135- cat /tmp/changelog.md >> "$GITHUB_OUTPUT"
136- echo "EOF" >> "$GITHUB_OUTPUT"
106+ if [ ${#COMMITS[@]} -eq 0 ]; then
107+ echo "_no new commits since last tag_" >> /tmp/changelog.md
108+ else
109+ for line in "${COMMITS[@]}"; do
110+ message="${line% *}"
111+ hash="${line##* }"
112+
113+ category=""
114+ case "$message" in
115+ feat*) category="🚀 feat" ;;
116+ fix*) category="🐛 fix" ;;
117+ perf*) category="⚡ perf" ;;
118+ refactor*) category="♻️ refactor" ;;
119+ test*) category="✅ test" ;;
120+ docs*) category="📝 docs" ;;
121+ chore*) category="🔧 chore" ;;
122+ ci*) category="👷 ci" ;;
123+ *) category="📦 other" ;;
124+ esac
125+
126+ clean_msg=$(echo "$message" | sed -E 's/^[a-z]+(\([^)]*\))?: ?//')
127+ echo "- **$category**: $clean_msg (\`$hash\`)" >> /tmp/changelog.md
128+ done
129+ fi
130+
131+ {
132+ echo "body<<EOF"
133+ cat /tmp/changelog.md
134+ echo "EOF"
135+ } >> "$GITHUB_OUTPUT"
137136
138137 release :
139138 name : Create GitHub Release
0 commit comments