Skip to content

Commit 24e8dcb

Browse files
committed
🚀 feat(ci): add automated release generation with version tagging
- Add automatic timestamp-based version generation (v2025.MM.DD.HHMM format) - Implement automatic GitHub release creation when changes are committed - Generate comprehensive release notes with recent commit history - Include API documentation links and usage instructions in releases - Add git tag creation and push functionality - Convert all release notes and comments to English - Only create releases when actual code changes are detected This enhancement automates the release process, providing better tracking of API data updates and improved user experience with detailed release documentation.
1 parent dfe6fc1 commit 24e8dcb

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

.github/workflows/build.yml

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ jobs:
6060
6161
- name: Commit and push changes
6262
if: ${{ steps.check.outputs.CHANGED == '2' || github.event_name == 'workflow_dispatch' || github.event_name == 'push' }}
63+
id: commit
6364
run: |
6465
if [ -n "$(git status --porcelain)" ]; then
6566
git config user.name "github-actions[bot]"
6667
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
6768
git add dist
6869
DT=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
6970
70-
# 根据不同触发事件设置提交信息
71+
# Set commit message based on trigger event
7172
if [ "${{ github.event_name }}" = "push" ]; then
7273
TRIGGER_MSG="triggered by push to ${{ github.ref_name }}"
7374
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
@@ -82,12 +83,65 @@ jobs:
8283
TRIGGER_MSG="triggered by ${{ github.event_name }}"
8384
fi
8485
85-
git commit -m "📦 chore(dist): update static API - ${TRIGGER_MSG} [${DT}]"
86+
COMMIT_MSG="📦 chore(dist): update static API - ${TRIGGER_MSG} [${DT}]"
87+
git commit -m "${COMMIT_MSG}"
8688
git push
89+
echo "COMMITTED=true" >> $GITHUB_OUTPUT
90+
echo "COMMIT_MESSAGE=${COMMIT_MSG}" >> $GITHUB_OUTPUT
8791
else
8892
echo "No changes to commit"
93+
echo "COMMITTED=false" >> $GITHUB_OUTPUT
8994
fi
9095
96+
- name: Generate version and create release
97+
if: ${{ steps.commit.outputs.COMMITTED == 'true' }}
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
run: |
101+
# Generate timestamp-based version number
102+
VERSION="v$(date -u +"%Y.%m.%d.%H%M")"
103+
echo "Generated version: $VERSION"
104+
105+
# Create git tag
106+
git tag $VERSION
107+
git push origin $VERSION
108+
109+
# Get recent commit messages for release notes
110+
RECENT_COMMITS=$(git log --oneline -10 --pretty=format:"- %s" | head -20)
111+
112+
# Create release notes
113+
cat > release_notes.md << EOF
114+
## 🚀 Automated Release $VERSION
115+
116+
**Build Time:** $(date -u +"%Y-%m-%d %H:%M:%S UTC")
117+
**Triggered By:** ${{ github.event_name }}
118+
119+
### 📋 Recent Changes
120+
121+
$RECENT_COMMITS
122+
123+
### 📦 API Data
124+
125+
This release contains the latest LLM model metadata:
126+
- Support for multiple AI provider model information
127+
- Auto-generated API indexes and detailed information
128+
- Price conversion configuration files
129+
130+
### 🔗 Usage
131+
132+
- **API Documentation:** https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
133+
- **Model List:** https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/api/index.json
134+
- **Complete Data:** https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/api/all.json
135+
136+
> This version is automatically built and released via GitHub Actions
137+
EOF
138+
139+
# Create release using GitHub CLI
140+
gh release create $VERSION \
141+
--title "🚀 LLM Metadata API $VERSION" \
142+
--notes-file release_notes.md \
143+
--latest
144+
91145
- name: Upload Pages artifact
92146
uses: actions/upload-pages-artifact@v3
93147
with:

0 commit comments

Comments
 (0)