forked from mg-chao/snow-shot
-
Notifications
You must be signed in to change notification settings - Fork 7
136 lines (115 loc) · 4.75 KB
/
test.yml
File metadata and controls
136 lines (115 loc) · 4.75 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
# Snow Shot 项目手动构建 Test 版本工作流
# 将显示在 GitHub 存储库的"操作"选项卡中的工作流名称
name: Test Build CI
# 指定此工作流的触发器
on:
workflow_dispatch:
jobs:
# 编译 Tauri 应用
build-app:
permissions:
contents: read
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# 安装 Node.js 和 pnpm
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: latest
# 安装 Rust
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
- name: Install rust target
run: rustup target add x86_64-pc-windows-msvc
# 使用 Rust 缓存,加快安装速度
- name: Rust cache
uses: swatinem/rust-cache@v2
with:
workspaces: src-tauri -> target
# 配置 pnpm 缓存
- name: Setup pnpm cache
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
# 安装 yarn
- name: Install yarn
run: npm install -g yarn
# 准备 Excalidraw 依赖
- name: Clone Excalidraw
run: |
cd ..
git clone https://github.com/mg-chao/excalidraw.git
cd excalidraw
git checkout custom/master
shell: bash
# 配置 yarn 缓存
- name: Cache yarn dependencies
uses: actions/cache@v4
with:
path: |
~/.yarn/cache
~/.cache/yarn
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
# 安装 Excalidraw 依赖
- name: Install Excalidraw dependencies
run: |
cd ../excalidraw
yarn install --frozen-lockfile
cd ../snow-shot
shell: bash
# 创建 .env 文件以支持联网功能
- name: Create .env file
run: echo "PUBLIC_ONLINE_STATUS=true" > .env
shell: bash
# 安装前端依赖并打包
- name: Install app dependencies and build web
run: pnpm install --frozen-lockfile
# 构建 Excalidraw
- name: Build Excalidraw
run: pnpm update:excalidraw
# 下载并配置 onnxruntime (Windows only)
- name: Download and setup onnxruntime (Windows)
run: |
# 下载 onnxruntime
Invoke-WebRequest -Uri "https://github.com/supertone-inc/onnxruntime-build/releases/download/v1.22.2/onnxruntime-win-x64-static_lib-1.22.2.zip" -OutFile "onnxruntime.zip"
# 解压文件
Expand-Archive -Path "onnxruntime.zip" -DestinationPath "onnxruntime-temp" -Force
# 查找并移动 lib 文件夹到 src-tauri
$libPath = Get-ChildItem -Path "onnxruntime-temp" -Recurse -Directory -Filter "lib" | Select-Object -First 1
if ($libPath) {
Copy-Item -Path $libPath.FullName -Destination "src-tauri\lib" -Recurse -Force
Write-Host "Successfully copied lib folder to src-tauri"
} else {
Write-Error "lib folder not found in extracted files"
exit 1
}
# 清理临时文件
Remove-Item -Path "onnxruntime.zip" -Force
Remove-Item -Path "onnxruntime-temp" -Recurse -Force
shell: pwsh
# 执行构建
- name: Build the app
uses: tauri-apps/tauri-action@v0
env:
CI: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
args: --target x86_64-pc-windows-msvc
# 上传构建产物到 Action 附件
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: snow-shot-windows-test-build
path: |
src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe