Skip to content

Commit 0254b74

Browse files
committed
Update publish.yml
1 parent 5ee514c commit 0254b74

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,64 @@ jobs:
9292
chmod +x *
9393
zip ../GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_linux-x64.zip -r *
9494
95+
- name: Checkout for changelog
96+
uses: actions/checkout@v6
97+
with:
98+
fetch-depth: 0
99+
100+
- name: Generate changelog
101+
run: |
102+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
103+
if [ -z "$PREVIOUS_TAG" ]; then
104+
LOG=$(git log --oneline --no-decorate -100)
105+
else
106+
LOG=$(git log "${PREVIOUS_TAG}..HEAD" --oneline --no-decorate)
107+
fi
108+
109+
FEATURES=""; FIXES=""; REFACTORS=""; TESTS=""; DOCS=""; CHORES=""; OTHERS=""
110+
111+
while IFS= read -r line; do
112+
[ -z "$line" ] && continue
113+
# Remove commit hash prefix
114+
msg=$(echo "$line" | sed -E 's/^[a-f0-9]+ //')
115+
case "$msg" in
116+
feat:*|feature:*) FEATURES="${FEATURES}- ${msg}"$'\n' ;;
117+
fix:*) FIXES="${FIXES}- ${msg}"$'\n' ;;
118+
refactor:*) REFACTORS="${REFACTORS}- ${msg}"$'\n' ;;
119+
test:*) TESTS="${TESTS}- ${msg}"$'\n' ;;
120+
docs:*) DOCS="${DOCS}- ${msg}"$'\n' ;;
121+
chore:*|cleanup:*|ci:*|build:*) CHORES="${CHORES}- ${msg}"$'\n' ;;
122+
*) OTHERS="${OTHERS}- ${msg}"$'\n' ;;
123+
esac
124+
done <<< "$LOG"
125+
126+
BODY=""
127+
append_section() {
128+
if [ -n "$2" ]; then
129+
BODY="${BODY}## $1"$'\n\n'"$2"$'\n'
130+
fi
131+
}
132+
133+
append_section "🚀 Features" "$FEATURES"
134+
append_section "🐛 Bug Fixes" "$FIXES"
135+
append_section "♻️ Refactoring" "$REFACTORS"
136+
append_section "✅ Tests" "$TESTS"
137+
append_section "📝 Documentation" "$DOCS"
138+
append_section "🔧 Chores" "$CHORES"
139+
append_section "📦 Other Changes" "$OTHERS"
140+
141+
[ -z "$BODY" ] && BODY="_No changes detected between tags._"
142+
143+
echo "$BODY" > changelog.md
144+
echo "=== Generated changelog ==="
145+
cat changelog.md
146+
95147
- name: Create Release
96148
uses: softprops/action-gh-release@v2
97149
with:
98150
tag_name: v${{ steps.ts.outputs.timestamp }}
99151
name: GeneralUpdate.Tools ${{ steps.ts.outputs.timestamp }}
152+
body_path: changelog.md
100153
files: |
101154
GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_win-x64.zip
102155
GeneralUpdate.Tools_${{ steps.ts.outputs.timestamp }}_linux-x64.zip

0 commit comments

Comments
 (0)