-
Notifications
You must be signed in to change notification settings - Fork 22
495 lines (433 loc) · 17.1 KB
/
release.yaml
File metadata and controls
495 lines (433 loc) · 17.1 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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
build-localbridge:
name: Build LocalBridge for ${{ matrix.name }}
runs-on: ${{ matrix.os }}
# 跳过测试版本 tag,允许手动触发
if: ${{ github.event_name == 'workflow_dispatch' || (!contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test')) }}
strategy:
matrix:
include:
- os: windows-latest
goos: windows
goarch: amd64
name: mpelb-windows-amd64.exe
- os: ubuntu-latest
goos: linux
goarch: amd64
name: mpelb-linux-amd64
- os: macos-15-intel
goos: darwin
goarch: amd64
name: mpelb-darwin-amd64
- os: macos-latest
goos: darwin
goarch: arm64
name: mpelb-darwin-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false
- name: Build LocalBridge
working-directory: LocalBridge
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION=${GITHUB_REF#refs/tags/v}
fi
go build -ldflags="-s -w -X main.Version=${VERSION}" -o ../build/${{ matrix.name }} ./cmd/lb
shell: bash
- name: Upload LocalBridge artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: build/${{ matrix.name }}
build-web:
runs-on: ubuntu-latest
# 跳过测试版本 tag,允许手动触发
if: ${{ github.event_name == 'workflow_dispatch' || (!contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test')) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: yarn
- name: Install dependencies
run: yarn install
- name: Modify config for production build
run: |
# 将configStore.ts中的globalConfig.dev改为false
sed -i 's/dev: true,/dev: false,/g' src/stores/configStore.ts
echo "已修改configStore.ts中的dev配置为false"
- name: Build project (stable)
run: yarn build --mode stable
- name: Clean up dist (stable)
run: rm -rf dist/readme dist/logo
- name: Create stable archive
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION="${{ github.ref_name }}"
fi
cd dist
zip -r ../MaaPipelineEditor-${VERSION}-stable.zip .
cd ..
shell: bash
- name: Build project (extremer)
run: yarn build --mode extremer
- name: Clean up dist (extremer)
run: rm -rf dist/readme dist/logo
- name: List dist contents
run: |
echo "=== Listing dist/ contents ==="
ls -la dist/
echo "=== Checking if index.html exists ==="
test -f dist/index.html && echo "✓ index.html found" || echo "✗ index.html NOT found"
shell: bash
- name: Upload extremer dist artifact
uses: actions/upload-artifact@v4
with:
name: extremer-dist
path: dist/
- name: Build docs
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION="${{ github.ref_name }}"
fi
cd docsite
yarn install
yarn build
cd ..
cd docsite/docs/.vitepress/dist
zip -r ../../../../MaaPipelineEditor-${VERSION}-docs.zip .
cd ../../../..
shell: bash
- name: Build landing
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION="${{ github.ref_name }}"
fi
cd Landing
yarn install --frozen-lockfile
yarn typecheck
yarn build
cd dist
zip -r ../../MaaPipelineEditor-${VERSION}-landing.zip .
cd ../..
shell: bash
- name: Upload web artifacts
uses: actions/upload-artifact@v4
with:
name: web-packages
path: |
MaaPipelineEditor-*-stable.zip
MaaPipelineEditor-*-docs.zip
MaaPipelineEditor-*-landing.zip
download-resources:
runs-on: ubuntu-latest
# 允许手动触发
if: ${{ github.event_name == 'workflow_dispatch' || (!contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test')) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache MaaFramework resources
uses: actions/cache@v3
with:
path: resources/
key: mfw-resources-${{ hashFiles('.github/workflows/release.yaml') }}-${{ github.run_id }}
restore-keys: |
mfw-resources-${{ hashFiles('.github/workflows/release.yaml') }}-
mfw-resources-
- name: Check cached resources
id: check-cache
run: |
if [ -d "resources/maafw-windows-amd64" ] && [ -d "resources/maafw-darwin-arm64" ]; then
echo "cache-hit=true" >> $GITHUB_OUTPUT
else
echo "cache-hit=false" >> $GITHUB_OUTPUT
fi
- name: Download MaaFramework resources
if: steps.check-cache.outputs.cache-hit != 'true'
env:
MAA_GH_TOKEN: ${{ secrets.MAA_GH_TOKEN }}
run: |
# 带认证的 curl 下载函数(优化版)
gh_curl() {
curl -L \
-H "Authorization: Bearer ${MAA_GH_TOKEN}" \
-H "Accept: application/octet-stream" \
-H "User-Agent: MaaPipelineEditor-CI/1.0" \
--retry 5 --retry-delay 3 --retry-all-errors \
--connect-timeout 60 --max-time 1200 \
--speed-time 30 --speed-limit 1000 \
"$@"
}
# 从 MaaFramework Release 自动获取最新版本
MFW_VERSION=$(curl -s -H "Authorization: Bearer ${MAA_GH_TOKEN}" \
https://api.github.com/repos/MaaXYZ/MaaFramework/releases \
| grep '"tag_name":' | head -1 | sed -E 's/.*"([^"]+)".*/\1/')
echo "MaaFramework latest version: ${MFW_VERSION}"
if [ -z "$MFW_VERSION" ]; then
echo "Failed to fetch latest MaaFramework version"
exit 1
fi
MFW_BASE_URL="https://github.com/MaaXYZ/MaaFramework/releases/download/${MFW_VERSION}"
mkdir -p resources
# 并行下载各平台资源
download_platform() {
local url="$1" zipfile="$2" destdir="$3"
gh_curl "${url}" -o "${zipfile}"
mkdir -p "${destdir}"
unzip "${zipfile}" -d "${destdir}/" || true
rm "${zipfile}"
}
download_platform "${MFW_BASE_URL}/MAA-win-x86_64-${MFW_VERSION}.zip" mfw-windows.zip resources/maafw-windows-amd64 &
download_platform "${MFW_BASE_URL}/MAA-linux-x86_64-${MFW_VERSION}.zip" mfw-linux.zip resources/maafw-linux-amd64 &
download_platform "${MFW_BASE_URL}/MAA-macos-x86_64-${MFW_VERSION}.zip" mfw-darwin-amd64.zip resources/maafw-darwin-amd64 &
download_platform "${MFW_BASE_URL}/MAA-macos-aarch64-${MFW_VERSION}.zip" mfw-darwin-arm64.zip resources/maafw-darwin-arm64 &
# OCR 资源(从 GitHub Raw 直接下载,更快更稳定)
(
mkdir -p resources/resource/model/ocr
# 使用 GitHub Raw CDN 下载,带认证和优化参数
gh_curl "https://raw.githubusercontent.com/MaaXYZ/MaaCommonAssets/main/OCR/ppocr_v5/zh_cn/det.onnx" -o resources/resource/model/ocr/det.onnx
gh_curl "https://raw.githubusercontent.com/MaaXYZ/MaaCommonAssets/main/OCR/ppocr_v5/zh_cn/rec.onnx" -o resources/resource/model/ocr/rec.onnx
gh_curl "https://raw.githubusercontent.com/MaaXYZ/MaaCommonAssets/main/OCR/ppocr_v5/zh_cn/keys.txt" -o resources/resource/model/ocr/keys.txt
gh_curl "https://raw.githubusercontent.com/MaaXYZ/MaaCommonAssets/main/OCR/ppocr_v5/zh_cn/README.md" -o resources/resource/model/ocr/README.md
) &
# 等待所有后台下载完成
wait
echo "All resources downloaded successfully"
- name: Upload resources artifact
uses: actions/upload-artifact@v4
with:
name: mfw-resources
path: resources/
build-extremer:
name: Build Extremer for ${{ matrix.platform }}
needs: [build-web, build-localbridge, download-resources]
runs-on: ${{ matrix.os }}
# 允许手动触发
if: ${{ github.event_name == 'workflow_dispatch' || (!contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test')) }}
strategy:
matrix:
include:
- os: windows-latest
platform: windows-amd64
mpelb: mpelb-windows-amd64.exe
mpelb_target: mpelb.exe
mfw_dir: maafw-windows-amd64
- os: ubuntu-latest
platform: linux-amd64
mpelb: mpelb-linux-amd64
mpelb_target: mpelb
mfw_dir: maafw-linux-amd64
- os: macos-15-intel
platform: darwin-amd64
mpelb: mpelb-darwin-amd64
mpelb_target: mpelb
mfw_dir: maafw-darwin-amd64
- os: macos-latest
platform: darwin-arm64
mpelb: mpelb-darwin-arm64
mpelb_target: mpelb
mfw_dir: maafw-darwin-arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false
- name: Install Wails
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev
- name: Download extremer dist
uses: actions/download-artifact@v4
with:
name: extremer-dist
path: Extremer/frontend/dist/
- name: Verify extremer dist download
run: |
echo "=== Listing Extremer/frontend/dist/ contents ==="
ls -la Extremer/frontend/dist/
echo "=== Checking if index.html exists ==="
test -f Extremer/frontend/dist/index.html && echo "✓ index.html found" || echo "✗ index.html NOT found"
shell: bash
- name: Download LocalBridge artifact
uses: actions/download-artifact@v4
with:
name: ${{ matrix.mpelb }}
path: Extremer/resources/
- name: Rename mpelb
run: mv Extremer/resources/${{ matrix.mpelb }} Extremer/resources/${{ matrix.mpelb_target }}
shell: bash
- name: Download MFW resources
uses: actions/download-artifact@v4
with:
name: mfw-resources
path: mfw-resources/
- name: Copy MFW resources
run: |
mkdir -p Extremer/resources/maafw
# 只复制 bin 文件夹以节省体积
if [ -d "mfw-resources/${{ matrix.mfw_dir }}/bin" ]; then
cp -r mfw-resources/${{ matrix.mfw_dir }}/bin Extremer/resources/maafw/ || true
fi
mkdir -p Extremer/resources/resource
cp -r mfw-resources/resource/* Extremer/resources/resource/ || true
shell: bash
- name: Set execute permission
if: matrix.os != 'windows-latest'
run: chmod +x Extremer/resources/${{ matrix.mpelb_target }}
- name: Build Extremer
working-directory: Extremer
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
wails build -tags webkit2_41 -ldflags="-X main.version=${VERSION}"
else
wails build -ldflags="-X main.version=${VERSION}"
fi
shell: bash
- name: Copy config file after build
run: |
mkdir -p Extremer/build/bin/config
cp Extremer/config/default.json Extremer/build/bin/config/default.json
shell: bash
- name: Package Extremer (Windows)
if: matrix.os == 'windows-latest'
run: |
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$VERSION = "test-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
} else {
$VERSION = "${{ github.ref_name }}"
}
New-Item -ItemType Directory -Force -Path package/MaaPipelineExtremer-${{ matrix.platform }}
Copy-Item Extremer/build/bin/MaaPipelineEditor.exe package/MaaPipelineExtremer-${{ matrix.platform }}/
Copy-Item -Recurse Extremer/resources package/MaaPipelineExtremer-${{ matrix.platform }}/
Copy-Item -Recurse Extremer/build/bin/config package/MaaPipelineExtremer-${{ matrix.platform }}/
cd package
Compress-Archive -Path MaaPipelineExtremer-${{ matrix.platform }} -DestinationPath MaaPipelineExtremer-${{ matrix.platform }}-$VERSION.zip
shell: pwsh
- name: Package Extremer (Unix)
if: matrix.os != 'windows-latest'
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION="test-$(date +%Y%m%d-%H%M%S)"
else
VERSION="${{ github.ref_name }}"
fi
mkdir -p package/MaaPipelineExtremer-${{ matrix.platform }}
cp Extremer/build/bin/MaaPipelineEditor package/MaaPipelineExtremer-${{ matrix.platform }}/ || cp -r Extremer/build/bin/MaaPipelineEditor.app package/MaaPipelineExtremer-${{ matrix.platform }}/ || true
cp -r Extremer/resources package/MaaPipelineExtremer-${{ matrix.platform }}/
cp -r Extremer/build/bin/config package/MaaPipelineExtremer-${{ matrix.platform }}/
cd package
zip -r MaaPipelineExtremer-${{ matrix.platform }}-${VERSION}.zip MaaPipelineExtremer-${{ matrix.platform }}
shell: bash
- name: Upload Extremer artifact
uses: actions/upload-artifact@v4
with:
name: extremer-${{ matrix.platform }}
path: package/*.zip
release:
needs: [build-web, build-localbridge, build-extremer]
runs-on: ubuntu-latest
# 仅在 tag 触发时执行发布,手动触发时跳过
if: ${{ github.event_name == 'push' && !contains(github.ref_name, 'beta') && !contains(github.ref_name, 'test') }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download web artifacts
uses: actions/download-artifact@v4
with:
name: web-packages
- name: Download LocalBridge artifacts
uses: actions/download-artifact@v4
with:
path: localbridge-artifacts
pattern: mpelb-*
merge-multiple: true
- name: Download Extremer artifacts
uses: actions/download-artifact@v4
with:
path: extremer-artifacts
pattern: extremer-*
merge-multiple: true
- name: Clean up redundant files
run: |
# 删除所有 artifacts 目录中的多余文件
find . -type f \( -name "index.html" -o -name "*.ico" -o -name "logo.png" -o -name "maafw.png" \) -delete
echo "已删除多余文件"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Generate Changelog
id: changelog
run: |
CURRENT_TAG="${{ github.ref_name }}"
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
node .github/scripts/render-release-notes.mjs \
--tag "$CURRENT_TAG" \
--previous-tag "$PREVIOUS_TAG" \
--update-logs src/data/updateLogs.ts \
--output CHANGELOG.md
# 输出到GitHub Actions
{
echo "changelog<<EOF"
cat CHANGELOG.md
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
MaaPipelineEditor-${{ github.ref_name }}-stable.zip
MaaPipelineEditor-${{ github.ref_name }}-docs.zip
MaaPipelineEditor-${{ github.ref_name }}-landing.zip
localbridge-artifacts/*
extremer-artifacts/*
body_path: CHANGELOG.md
generate_release_notes: false
draft: false
prerelease: false
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}