-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (230 loc) · 7.65 KB
/
build-and-publish.yml
File metadata and controls
264 lines (230 loc) · 7.65 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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: Build and Publish Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
env:
RELEASE_VERSION: ${{ github.ref_name }}
jobs:
publish-linux:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Debug environment
run: |
chmod +x ./bin/debug-env.sh
./bin/debug-env.sh
- name: Publish Linux (AppImage and deb)
run: |
echo "🐧 开始Linux构建..."
npm run publish:linux
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron-builder
- name: Verify Linux build output
run: |
echo "🔍 验证Linux构建输出..."
ls -la dist/
echo "✅ Linux构建完成"
publish-windows:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Debug environment
run: |
chmod +x ./bin/debug-env.sh
./bin/debug-env.sh
- name: Publish Windows
run: |
echo "🪟 开始Windows构建(包含Defender白名单自动配置)..."
npm run publish:win
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron-builder
- name: Verify Windows build output
run: |
echo "🔍 验证Windows构建输出..."
ls -la dist/
# 检查是否包含README文件和安装脚本
if (Test-Path "dist/README_WINDOWS.txt") {
Write-Host "✅ Windows用户说明文件已创建"
Get-Content "dist/README_WINDOWS.txt"
} else {
Write-Host "⚠️ Windows用户说明文件未找到"
}
# 检查NSIS配置
if (Test-Path "build/installer.nsh") {
Write-Host "✅ NSIS安装脚本配置存在"
} else {
Write-Host "⚠️ NSIS安装脚本配置未找到"
}
shell: powershell
publish-macos:
runs-on: macos-26
timeout-minutes: 60
strategy:
matrix:
arch: [x64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Debug environment
run: |
chmod +x ./bin/debug-env.sh
./bin/debug-env.sh
- name: Debug macOS build environment
run: |
echo "=== macOS Build Environment (${{ matrix.arch }}) ==="
uname -a
sw_vers
xcodebuild -version || echo "Xcode not available"
echo "Available disk space:"
df -h
echo "Memory usage:"
vm_stat
echo "Building for architecture: ${{ matrix.arch }}"
- name: Setup macOS signing tools
run: |
echo "🔧 准备macOS签名工具..."
# 确保codesign工具可用
which codesign || echo "Warning: codesign not found"
# 设置脚本权限
chmod +x ./bin/fix-macos.sh
chmod +x ./bin/user-fix-macos.sh
echo "✅ macOS工具准备完成"
- name: Publish macOS ${{ matrix.arch }}
run: |
echo "Starting macOS ${{ matrix.arch }} build with verbose output..."
echo "🍎 构建将自动处理签名和用户体验优化..."
npm run publish:mac:${{ matrix.arch }}
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
DEBUG: electron-builder
CSC_IDENTITY_AUTO_DISCOVERY: false
ELECTRON_BUILDER_ALLOW_UNRESOLVED_DEPENDENCIES: true
# 确保afterPack钩子能正常执行
ELECTRON_IS_DEV: 0
- name: Verify macOS build output
run: |
echo "🔍 验证macOS构建输出..."
ls -la dist/
# 检查是否包含README文件
if [ -f "dist/README_MACOS.txt" ]; then
echo "✅ 用户说明文件已创建"
cat dist/README_MACOS.txt
else
echo "⚠️ 用户说明文件未找到"
fi
# 检查.app文件
find dist/ -name "*.app" -type d | head -5 | while read app_path; do
if [ -d "$app_path" ]; then
echo "📱 找到应用: $app_path"
# 检查签名状态
codesign -dv "$app_path" 2>&1 || echo "签名检查完成"
fi
done
cleanup-release:
runs-on: ubuntu-latest
needs: [publish-linux, publish-windows, publish-macos]
if: always() && (needs.publish-linux.result == 'success' || needs.publish-windows.result == 'success' || needs.publish-macos.result == 'success')
permissions:
contents: write
actions: read
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Debug GitHub token and permissions
run: |
chmod +x ./bin/debug-github.sh
./bin/debug-github.sh
env:
GITHUB_TOKEN: ${{ secrets.atriordsa }}
- name: Clean unwanted files from release
run: |
chmod +x ./bin/cleanup-release.sh
./bin/cleanup-release.sh
env:
GITHUB_TOKEN: ${{ secrets.atriordsa }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
upload-to-cos:
runs-on: ubuntu-latest
timeout-minutes: 180 # 3小时超时,适合大文件上传
needs: [cleanup-release]
if: always() && needs.cleanup-release.result == 'success'
steps:
- name: Checkout repository first
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Get release info
run: |
chmod +x ./bin/get-release-info.sh
./bin/get-release-info.sh
env:
GITHUB_TOKEN: ${{ secrets.atriordsa }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Download release assets
run: |
chmod +x ./bin/download-assets.sh
./bin/download-assets.sh
env:
GITHUB_TOKEN: ${{ secrets.atriordsa }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_REF_NAME: ${{ github.ref_name }}
- name: Create release index
run: node scripts/create-release-index.js
env:
TAG_NAME: ${{ github.ref_name }}
CDN_URL: ${{ secrets.CDN_URL }}
GITHUB_TOKEN: ${{ secrets.atriordsa }}
- name: Upload all files to COS using npm script
run: npm run upload:cos
env:
COS_SECRET_ID: ${{ secrets.COS_SECRET_ID }}
COS_SECRET_KEY: ${{ secrets.COS_SECRET_KEY }}
COS_REGION: ${{ secrets.COS_REGION }}
COS_BUCKET: ${{ secrets.COS_BUCKET }}
COS_DOMAIN: ${{ secrets.COS_DOMAIN }}
TAG_NAME: ${{ github.ref_name }}
- name: Display upload summary
run: |
chmod +x ./bin/display-upload-summary.sh
./bin/display-upload-summary.sh
env:
TAG_NAME: ${{ github.ref_name }}
COS_DOMAIN: ${{ secrets.COS_DOMAIN }}
CDN_URL: ${{ secrets.CDN_URL }}