Repository navigation
147 lines (125 loc) · 4.56 KB
/
Copy pathtest.yml
File metadata and controls
147 lines (125 loc) · 4.56 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
# 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@v6
# 获取 Excalidraw 的 commit hash
- name: Get Excalidraw Commit Hash
id: excalidraw-info
run: |
$hash = git ls-remote https://github.com/mg-chao/excalidraw.git refs/heads/custom/master | Select-Object -First 1 | ForEach-Object { $_.Split()[0] }
echo "hash=$hash" >> $env:GITHUB_OUTPUT
shell: pwsh
# 缓存 Excalidraw 构建
- name: Cache Excalidraw Build
id: cache-excalidraw
uses: actions/cache@v5
with:
path: excalidraw
key: excalidraw-build-${{ steps.excalidraw-info.outputs.hash }}
# 构建 Excalidraw
- name: Build Excalidraw
if: steps.cache-excalidraw.outputs.cache-hit != 'true'
run: |
git clone https://github.com/mg-chao/excalidraw.git
cd excalidraw
git checkout custom/master
npm install -g yarn
yarn install --frozen-lockfile
yarn build:packages
shell: bash
# 保存 Excalidraw 缓存
- name: Save Excalidraw Cache
if: steps.cache-excalidraw.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
path: excalidraw
key: excalidraw-build-${{ steps.excalidraw-info.outputs.hash }}
# 移动 Excalidraw 目录
- name: Move Excalidraw to Sibling Directory
run: |
Move-Item -Path ./excalidraw -Destination ../excalidraw
shell: pwsh
# 安装 Node.js 和 pnpm
- name: Setup node
uses: actions/setup-node@v6
with:
node-version: 22
- name: Setup pnpm
uses: pnpm/action-setup@v6
# 安装 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
shared-key: "snow-shot-windows-build"
cache-on-failure: true
# 配置 pnpm 缓存
- name: Setup pnpm cache
uses: actions/setup-node@v6
with:
node-version: 22
cache: pnpm
# 创建 .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: Link Excalidraw
run: |
pnpm update @mg-chao/excalidraw
shell: pwsh
# 下载并配置 onnxruntime (Windows only)
- name: Download and setup onnxruntime (Windows)
id: onnx-setup
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 }}
with:
args: --target x86_64-pc-windows-msvc
# 上传构建产物到 Action 附件
- name: Upload build artifact
uses: actions/upload-artifact@v7
with:
name: snow-shot-windows-test-build
path: |
src-tauri/target/x86_64-pc-windows-msvc/release/bundle/nsis/*.exe