-
Notifications
You must be signed in to change notification settings - Fork 602
249 lines (219 loc) · 8.05 KB
/
deps-build-windows-nsis.yaml
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
name: "[Single] Build Windows NSIS"
on:
workflow_dispatch:
inputs:
portable:
description: "Build Portable pkg"
required: true
type: boolean
default: false
fixed-webview:
description: "Fixed WebView"
required: true
type: boolean
default: false
nightly:
description: "Nightly prepare"
required: true
type: boolean
default: false
tag:
description: "Release Tag"
required: true
type: string
arch:
type: choice
description: "build arch target"
required: true
default: "x86_64"
options:
- x86_64
- i686
- aarch64
workflow_call:
inputs:
portable:
description: "Build Portable pkg"
required: true
type: boolean
default: false
fixed-webview:
description: "Fixed WebView"
required: true
type: boolean
default: false
nightly:
description: "Nightly prepare"
required: true
type: boolean
default: false
tag:
description: "Release Tag"
required: true
type: string
arch:
type: string
description: "build arch target"
required: true
default: "x86_64"
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust stable
run: |
rustup install stable --profile minimal --no-self-update
rustup default stable
- name: Setup Rust target
if: ${{ inputs.arch != 'x86_64' }}
run: |
rustup target add ${{ inputs.arch }}-pc-windows-msvc
- uses: Swatinem/rust-cache@v2
with:
workspaces: "./backend/"
prefix-key: "rust-stable"
key: windows-latest
shared-key: "release"
- name: Install Node latest
uses: actions/setup-node@v4
with:
node-version: latest
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
run_install: false
- name: Install Node.js dependencies
run: |
pnpm i
- name: Prepare sidecars and resources
run: |
$condition = '${{ inputs.arch }}'
switch ($condition) {
'x86_64' {
pnpm check
}
'i686' {
pnpm check --arch ia32 --sidecar-host i686-pc-windows-msvc
}
'aarch64' {
pnpm check --arch arm64 --sidecar-host aarch64-pc-windows-msvc
}
}
- name: Download fixed WebView
if: ${{ inputs.fixed-webview == true }}
run: |
$condition = '${{ inputs.arch }}'
switch ($condition) {
'x86_64' {
$arch= 'x64'
}
'i686' {
$arch = 'x86'
}
'aarch64' {
$arch = 'arm64'
}
}
$version = '127.0.2651.105'
$uri = "https://github.com/westinyang/WebView2RuntimeArchive/releases/download/$version/Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
$outfile = "Microsoft.WebView2.FixedVersionRuntime.$version.$arch.cab"
echo "Downloading $uri to $outfile"
invoke-webrequest -uri $uri -outfile $outfile
echo "Download finished, attempting to extract"
expand.exe $outfile -F:* ./backend/tauri
echo "Extraction finished"
- name: Prepare (Windows NSIS and Portable)
if: ${{ inputs.fixed-webview == false }}
run: ${{ inputs.nightly == true && 'pnpm prepare:nightly --nsis' || 'pnpm prepare:release --nsis' }}
- name: Prepare (Windows NSIS and Portable) with fixed WebView
if: ${{ inputs.fixed-webview == true }}
run: ${{ inputs.nightly == true && 'pnpm prepare:nightly --nsis --fixed-webview' || 'pnpm prepare:release --nsis --fixed-webview' }}
- name: Build UI
run: |
pnpm -F ui build
# TODO: optimize strategy
- name: Tauri build x86_64
if: ${{ inputs.arch == 'x86_64' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
run: |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json' || '-f default-meta' }}
- name: Tauri build i686
if: ${{ inputs.arch == 'i686' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
run: |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json --target i686-pc-windows-msvc' || '-f default-meta --target i686-pc-windows-msvc' }}
- name: Tauri build arm64
if: ${{ inputs.arch == 'aarch64' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
run: |
pnpm tauri build ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json --target aarch64-pc-windows-msvc' || '-f default-meta --target aarch64-pc-windows-msvc' }}
- name: Rename fixed webview bundle name
if: ${{ inputs.fixed-webview == true }}
run: |
$files = Get-ChildItem -Path "./backend/target" -Recurse -Include "*.exe", "*.zip", "*.zip.sig" | Where-Object { $_.FullName -like "*\bundle\*" }
$condition = '${{ inputs.arch }}'
switch ($condition) {
'x86_64' {
$arch= 'x64'
}
'i686' {
$arch = 'x86'
}
'aarch64' {
$arch = 'arm64'
}
}
foreach ($file in $files) {
echo "Renaming $file"
$newname = $file.FullName -replace $arch, "fixed-webview-$arch"
Rename-Item -Path $file -NewName $newname
}
- name: Upload to release
run: |
$files = Get-ChildItem -Path "./backend/target" -Recurse -Include "*.exe", "*.zip", "*.zip.sig" | Where-Object { $_.FullName -like "*\bundle\*" }
foreach ($file in $files) {
echo "Uploading $file"
gh release upload ${{ inputs.tag }} "$file" --clobber
}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Portable Bundle
if: ${{ inputs.portable == true }}
run: |
pnpm portable ${{ inputs.fixed-webview == true && '--fixed-webview' || '' }}
env:
RUST_ARCH: ${{ inputs.arch }}
TAG_NAME: ${{ inputs.tag }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
NIGHTLY: ${{ inputs.nightly == true && 'true' || 'false' }}
VITE_WIN_PORTABLE: 1
- name: Upload NSIS Installer
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-windows-${{ inputs.arch }}${{ inputs.fixed-webview == true && '-fixed-webview' || '' }}-nsis-installer
path: |
./backend/target/**/bundle/*.exe
- name: Upload portable
if: ${{ inputs.portable == true }}
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-windows-${{ inputs.arch }}${{ inputs.fixed-webview == true && '-fixed-webview' || '' }}-portable
path: |
./*_portable.zip