Skip to content

Commit 28fd0bd

Browse files
committed
chore(build): enhance release workflow with copilot commit diff generation
1 parent a3bd80b commit 28fd0bd

File tree

2 files changed

+108
-18
lines changed

2 files changed

+108
-18
lines changed

.github/workflows/release.yml

Lines changed: 107 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ on:
77
description: 'Version to release (leave empty to use package.json version)'
88
required: false
99
type: string
10+
previous_tag:
11+
description: 'Previous tag to compare (leave empty for auto-detect)'
12+
required: false
13+
type: string
1014

1115
jobs:
1216
release:
1317
runs-on: ubuntu-latest
1418
permissions:
1519
contents: write
20+
models: read
1621
steps:
1722
- name: Checkout
1823
uses: actions/checkout@v4
@@ -51,6 +56,96 @@ jobs:
5156
echo "✅ Tag v${{ steps.version.outputs.version }} does not exist"
5257
fi
5358
59+
- name: Get previous tag
60+
id: prev_tag
61+
run: |
62+
if [ -n "${{ inputs.previous_tag }}" ]; then
63+
PREV_TAG="${{ inputs.previous_tag }}"
64+
else
65+
PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
66+
fi
67+
echo "tag=$PREV_TAG" >> $GITHUB_OUTPUT
68+
echo "📌 Previous tag: $PREV_TAG"
69+
70+
- name: Get commit diff
71+
id: diff
72+
run: |
73+
if [ -n "${{ steps.prev_tag.outputs.tag }}" ]; then
74+
COMMITS=$(git log ${{ steps.prev_tag.outputs.tag }}..HEAD --pretty=format:"- %s" --no-merges | head -50)
75+
FILES_CHANGED=$(git diff --name-only ${{ steps.prev_tag.outputs.tag }}..HEAD | head -30)
76+
else
77+
COMMITS=$(git log --pretty=format:"- %s" --no-merges -20)
78+
FILES_CHANGED=$(git diff --name-only HEAD~20..HEAD 2>/dev/null | head -30)
79+
fi
80+
81+
# Save to files for fallback
82+
echo "$COMMITS" > /tmp/commits.txt
83+
echo "$FILES_CHANGED" > /tmp/files.txt
84+
85+
# Output commits for Copilot action
86+
echo "commits<<EOF" >> $GITHUB_OUTPUT
87+
echo "$COMMITS" >> $GITHUB_OUTPUT
88+
echo "EOF" >> $GITHUB_OUTPUT
89+
90+
# Output for debugging
91+
echo "📝 Recent commits:"
92+
echo "$COMMITS"
93+
94+
- name: Generate release summary with GitHub Copilot
95+
id: summary
96+
uses: github/copilot-models-action@v1
97+
with:
98+
model: gpt-4o
99+
prompt: |
100+
You are a release notes writer for a Ghost blog theme called "Attegi".
101+
Based on the git commits below, generate a concise release summary.
102+
103+
Commits:
104+
${{ steps.diff.outputs.commits }}
105+
106+
Requirements:
107+
- Group into: ✨ New Features, 🐛 Bug Fixes, 🎨 Improvements, 📝 Documentation
108+
- Only include categories with changes
109+
- Keep each item to 1 line
110+
- Maximum 10 items
111+
- No code fences
112+
- If minimal changes, write "Minor updates and improvements"
113+
114+
- name: Fallback summary
115+
id: fallback
116+
if: failure() || steps.summary.outputs.response == ''
117+
run: |
118+
# Generate simple summary from commits
119+
COMMITS=$(cat /tmp/commits.txt | head -10)
120+
121+
# Categorize commits
122+
FEATURES=$(echo "$COMMITS" | grep -iE "^- (feat|add|new)" | head -5 || true)
123+
FIXES=$(echo "$COMMITS" | grep -iE "^- (fix|bug|patch)" | head -3 || true)
124+
IMPROVEMENTS=$(echo "$COMMITS" | grep -iE "^- (improve|update|refactor|enhance|style)" | head -3 || true)
125+
DOCS=$(echo "$COMMITS" | grep -iE "^- (doc|readme)" | head -2 || true)
126+
127+
SUMMARY=""
128+
if [ -n "$FEATURES" ]; then
129+
SUMMARY="${SUMMARY}#### ✨ New Features\n${FEATURES}\n\n"
130+
fi
131+
if [ -n "$FIXES" ]; then
132+
SUMMARY="${SUMMARY}#### 🐛 Bug Fixes\n${FIXES}\n\n"
133+
fi
134+
if [ -n "$IMPROVEMENTS" ]; then
135+
SUMMARY="${SUMMARY}#### 🎨 Improvements\n${IMPROVEMENTS}\n\n"
136+
fi
137+
if [ -n "$DOCS" ]; then
138+
SUMMARY="${SUMMARY}#### 📝 Documentation\n${DOCS}\n\n"
139+
fi
140+
141+
if [ -z "$SUMMARY" ]; then
142+
SUMMARY="Minor updates and improvements"
143+
fi
144+
145+
echo "response<<EOF" >> $GITHUB_OUTPUT
146+
echo -e "$SUMMARY" >> $GITHUB_OUTPUT
147+
echo "EOF" >> $GITHUB_OUTPUT
148+
54149
- name: Build and package
55150
run: |
56151
npx grunt clean:dist
@@ -97,6 +192,10 @@ jobs:
97192
98193
${{ steps.package.outputs.description }}
99194
195+
### 📝 What's Changed
196+
197+
${{ steps.summary.outputs.response || steps.fallback.outputs.response || 'See commits below for details.' }}
198+
100199
### 📥 Installation
101200
102201
1. **Download** `attegi.zip` from the assets below
@@ -110,23 +209,14 @@ jobs:
110209
- **Documentation**: [README.md](https://github.com/${{ github.repository }}/blob/main/README.md)
111210
- **中文文档**: [README_zh.md](https://github.com/${{ github.repository }}/blob/main/README_zh.md)
112211
113-
### ✨ Features
114-
115-
- 🎨 Dual theme support (Light/Dark/System)
116-
- 📱 Mobile optimized & responsive
117-
- 💻 Enhanced code blocks with syntax highlighting
118-
- 🧭 Smart post navigation
119-
- 🌍 32 language translations
120-
- ♿ WCAG accessible
121-
- 🚀 Optimized performance
122-
123212
### 📊 Package Info
124213
125-
- **Size**: ${{ steps.package.outputs.size_kb }}
126-
- **Ghost Version**: ${{ steps.package.outputs.ghost_version }}
127-
- **Validation**: ✅ Passed GScan
128-
- **License**: MIT
129-
130-
### 📝 What's Changed
214+
| Item | Value |
215+
|------|-------|
216+
| Size | ${{ steps.package.outputs.size_kb }} |
217+
| Ghost Version | ${{ steps.package.outputs.ghost_version }} |
218+
| Validation | ✅ Passed GScan |
219+
| License | MIT |
131220
132-
See the full changelog below.
221+
---
222+
*Release notes generated with GitHub Copilot*

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "attegi",
33
"description": "Attegi is an elegant and dynamic Ghost theme, with a modern design, deep support for Ghost, and specially optimized for mobile devices.",
44
"demo": "https://attegi.tutuis.me",
5-
"version": "6.8.2",
5+
"version": "6.9.0",
66
"engines": {
77
"ghost": ">=5.0.0"
88
},

0 commit comments

Comments
 (0)