Repository navigation
90 lines (77 loc) · 2.83 KB
/
Copy pathdesktop-build.yml
File metadata and controls
90 lines (77 loc) · 2.83 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
name: Desktop Build
# 仅当版本号变更(VERSION 文件修改的 push)或手动触发时打包;
# 打包完成后自动发布/更新同名 GitHub Release 并附上安装包。
on:
workflow_dispatch:
push:
branches: [master]
paths: ["VERSION"]
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
label: windows-x64
- os: macos-latest
label: macos-universal
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: desktop
steps:
- uses: actions/checkout@v4
- name: 读取版本号
id: version
shell: bash
run: echo "ver=$(tr -d ' \r\n' < ../VERSION)" >> "$GITHUB_OUTPUT"
- name: 安装 Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: 安装 Rust(macOS 附带 universal 双架构 target)
uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-darwin,aarch64-apple-darwin
- name: Rust 缓存
uses: swatinem/rust-cache@v2
with:
workspaces: desktop/src-tauri
- name: 同步版本号(VERSION → tauri.conf/package.json/Cargo.toml)
run: node scripts/sync-version.mjs
- name: 同步 UI(从 templates/ + static/ 生成)
run: node scripts/sync-ui.mjs
- name: 安装前端依赖
run: npm install --no-fund --no-audit
- name: 构建(Windows 出 NSIS/MSI,macOS 出 universal App/Dmg)
shell: bash
run: |
if [ "$RUNNER_OS" = "macOS" ]; then
npm run tauri build -- --target universal-apple-darwin
else
npm run tauri build
fi
- name: 上传 Artifacts(90 天)
uses: actions/upload-artifact@v4
with:
name: ScriptDeck-${{ matrix.label }}-${{ steps.version.outputs.ver }}
path: |
desktop/src-tauri/target/release/bundle/**/*.exe
desktop/src-tauri/target/release/bundle/**/*.msi
desktop/src-tauri/target/release/bundle/**/*.dmg
desktop/src-tauri/target/universal-apple-darwin/release/bundle/**/*.dmg
desktop/src-tauri/target/universal-apple-darwin/release/bundle/**/*.app.tar.gz
if-no-files-found: error
- name: 发布/更新 GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
TAG="v${{ steps.version.outputs.ver }}"
FILES=$(find src-tauri/target -path "*bundle*" \( -name "*.exe" -o -name "*.msi" -o -name "*.dmg" -o -name "*.app.tar.gz" \) | sort -u | tr '\n' ' ')
echo " attaching: $FILES"
gh release create "$TAG" --title "ScriptDeck $TAG" --generate-notes $FILES \
|| gh release upload "$TAG" $FILES --clobber