-
Notifications
You must be signed in to change notification settings - Fork 77
242 lines (211 loc) · 8.45 KB
/
Copy pathrelease.yml
File metadata and controls
242 lines (211 loc) · 8.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
name: 🚀 Release
on:
push:
tags:
- "v*"
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: "Release version (e.g., v1.0.0)"
required: true
type: string
env:
NODE_VERSION: "22"
permissions:
contents: write
jobs:
# ============================================================================
# 预发布验证
# ============================================================================
pre-release-validation:
name: 🔍 Pre-Release Validation
runs-on: ubuntu-latest
timeout-minutes: 20
outputs:
version: ${{ steps.version.outputs.version }}
should-deploy: ${{ steps.validation.outputs.should-deploy }}
steps:
- name: 📥 Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Setup PNPM
uses: pnpm/action-setup@v6
with:
cache: true
- name: 📦 Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📥 Install dependencies
run: pnpm ci
- name: 🏷️ Extract version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION=${GITHUB_REF#refs/tags/}
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION" >> $GITHUB_STEP_SUMMARY
- name: 🧪 Run full test suite
run: |
echo "## 🧪 Running Full Test Suite" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
pnpm run test:run
echo "✅ All tests passed!" >> $GITHUB_STEP_SUMMARY
- name: 🔍 Validate code quality
run: |
pnpm run lint
pnpm run type-check 2>/dev/null || pnpm exec tsc --noEmit
echo "✅ Code quality checks passed!" >> $GITHUB_STEP_SUMMARY
- name: 🏗️ Test build
run: |
pnpm run build
echo "✅ Build successful!" >> $GITHUB_STEP_SUMMARY
- name: ✅ Validation summary
id: validation
run: |
echo "should-deploy=true" >> $GITHUB_OUTPUT
echo "" >> $GITHUB_STEP_SUMMARY
echo "🎉 **Pre-release validation completed successfully!**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Ready for release build." >> $GITHUB_STEP_SUMMARY
# ============================================================================
# 构建发布包
# ============================================================================
build-release:
name: 🏗️ Build Release
runs-on: ubuntu-latest
needs: pre-release-validation
if: needs.pre-release-validation.outputs.should-deploy == 'true'
steps:
- name: 📥 Checkout code
uses: actions/checkout@v7
- name: Setup PNPM
uses: pnpm/action-setup@v6
with:
cache: true
- name: 📦 Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: 📥 Install dependencies
run: pnpm ci
- name: 🏗️ Build for production
run: |
pnpm run build
echo "## 🏗️ Build Information" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ needs.pre-release-validation.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Node.js**: ${{ env.NODE_VERSION }}" >> $GITHUB_STEP_SUMMARY
echo "- **Build Time**: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
- name: 📦 Create zip artifacts
run: |
set -euo pipefail
if [[ ! -s out/index.html ]]; then
echo "Console build is missing out/index.html" >&2
exit 1
fi
mkdir -p artifacts
(
cd ./out
zip -r ../artifacts/rustfs-console-latest.zip .
)
mkdir -p artifacts/${{ needs.pre-release-validation.outputs.version }}
(
cd ./out
zip -r ../artifacts/${{ needs.pre-release-validation.outputs.version }}/rustfs-console-${{ needs.pre-release-validation.outputs.version }}.zip .
)
- name: 📤 Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: release-build-${{ needs.pre-release-validation.outputs.version }}
path: |
artifacts/*.zip
artifacts/**/*.zip
retention-days: 90
- name: 📊 Build size analysis
run: |
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📊 Build Size Analysis" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -d "out" ]; then
total_size=$(du -sh out | cut -f1)
echo "- **Total Build Size**: $total_size" >> $GITHUB_STEP_SUMMARY
echo "- **File Breakdown**:" >> $GITHUB_STEP_SUMMARY
find out -type f \( -name "*.js" -o -name "*.css" -o -name "*.html" \) 2>/dev/null | head -10 | while read file; do
size=$(du -sh "$file" 2>/dev/null | cut -f1)
echo " - $(basename "$file"): $size" >> $GITHUB_STEP_SUMMARY
done
fi
# ============================================================================
# 创建 GitHub Release
# ============================================================================
create-release:
name: 📝 Create GitHub Release
runs-on: ubuntu-latest
needs: [pre-release-validation, build-release]
if: needs.pre-release-validation.outputs.should-deploy == 'true' && github.event_name == 'push'
steps:
- name: 📥 Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: 📥 Download release artifact
uses: actions/download-artifact@v7
with:
name: release-build-${{ needs.pre-release-validation.outputs.version }}
path: release-assets
- name: 📝 Generate changelog
id: changelog
run: |
echo "## 🎉 What's New in ${{ needs.pre-release-validation.outputs.version }}" > CHANGELOG.md
echo "" >> CHANGELOG.md
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREVIOUS_TAG" ]; then
echo "### 🔄 Changes since $PREVIOUS_TAG" >> CHANGELOG.md
echo "" >> CHANGELOG.md
git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD >> CHANGELOG.md
else
echo "### 🎉 Initial Release" >> CHANGELOG.md
echo "" >> CHANGELOG.md
fi
- name: 🏷️ Create release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.pre-release-validation.outputs.version }}
name: Release ${{ needs.pre-release-validation.outputs.version }}
body_path: CHANGELOG.md
draft: false
prerelease: ${{ contains(needs.pre-release-validation.outputs.version, '-') }}
files: release-assets/**/rustfs-console-${{ needs.pre-release-validation.outputs.version }}.zip
fail_on_unmatched_files: true
# ============================================================================
# 发布后通知
# ============================================================================
post-release:
name: 📢 Post-Release Notifications
runs-on: ubuntu-latest
needs: [pre-release-validation, create-release]
if: always() && needs.pre-release-validation.outputs.should-deploy == 'true'
steps:
- name: 📢 Success notification
if: needs.create-release.result == 'success'
run: |
echo "# 🎉 Release Successful!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## 📋 Release Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ needs.pre-release-validation.outputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Status**: ✅ Released Successfully" >> $GITHUB_STEP_SUMMARY
- name: 📢 Failure notification
if: needs.create-release.result == 'failure'
run: |
echo "# ❌ Release Failed!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Release creation failed. Please check the logs and retry." >> $GITHUB_STEP_SUMMARY