-
Notifications
You must be signed in to change notification settings - Fork 604
214 lines (196 loc) · 7.04 KB
/
deps-build-linux.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
name: "[Single] Build Linux"
on:
workflow_dispatch:
inputs:
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
- armel
- armhf
workflow_call:
inputs:
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: ubuntu-24.04 # 需要手动升级到 24.04
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 Cargo binstall
if: ${{ inputs.arch != 'x86_64' }}
uses: cargo-bins/cargo-binstall@main
- name: Setup Cross Toolchain
if: ${{ inputs.arch != 'x86_64' }}
shell: bash
run: |
case "${{ inputs.arch }}" in
"i686")
rustup target add i686-unknown-linux-gnu
;;
"aarch64")
rustup target add aarch64-unknown-linux-gnu
;;
"armel")
rustup target add armv7-unknown-linux-gnueabi
;;
"armhf")
rustup target add armv7-unknown-linux-gnueabihf
;;
esac
cargo binstall -y cross
- name: Setup Toolchain
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libxdo-dev libappindicator3-dev librsvg2-dev patchelf openssl
- uses: Swatinem/rust-cache@v2
with:
workspaces: "./backend/"
prefix-key: "rust-stable"
key: ubuntu-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
shell: bash
run: |
case "${{ inputs.arch }}" in
"x86_64")
pnpm check
;;
"i686")
pnpm check --arch ia32 --sidecar-host i686-unknown-linux-gnu
;;
"aarch64")
pnpm check --arch arm64 --sidecar-host aarch64-unknown-linux-gnu
;;
"armel")
pnpm check --arch armel --sidecar-host armv7-unknown-linux-gnueabi
;;
"armhf")
pnpm check --arch arm --sidecar-host armv7-unknown-linux-gnueabihf
;;
esac
- name: Nightly Prepare
if: ${{ inputs.nightly == true }}
run: |
pnpm prepare:nightly
- name: Build UI
run: |
pnpm -F ui build
- name: Tauri build (x86_64)
uses: tauri-apps/tauri-action@v0
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' }}
with:
tagName: ${{ inputs.tag }}
releaseName: "Clash Nyanpasu Dev"
releaseBody: "More new features are now supported."
releaseDraft: false
prerelease: true
tauriScript: pnpm tauri
args: ${{ inputs.nightly == true && '-f nightly -c ./backend/tauri/tauri.nightly.conf.json' || '-f default-meta' }}
- name: Tauri build and upload (cross)
if: ${{ inputs.arch != 'x86_64' }}
shell: bash
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: |
case "${{ inputs.arch }}" in
"i686")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target i686-unknown-linux-gnu -b "rpm,deb,updater"' || 'pnpm build -r cross --target i686-unknown-linux-gnu -b "rpm,deb,updater"' }}
;;
"aarch64")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target aarch64-unknown-linux-gnu -b "rpm,deb,updater"' || 'pnpm build -r cross --target aarch64-unknown-linux-gnu -b "rpm,deb,updater"' }}
;;
"armel")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target armv7-unknown-linux-gnueabi -b "rpm,deb,updater"' || 'pnpm build -r cross --target armv7-unknown-linux-gnueabi -b "rpm,deb,updater"' }}
;;
"armhf")
${{ inputs.nightly == true && 'pnpm build:nightly -r cross --target armv7-unknown-linux-gnueabihf -b "rpm,deb,updater"' || 'pnpm build -r cross --target armv7-unknown-linux-gnueabihf -b "rpm,deb,updater"' }}
;;
esac
find ./backend/target \( -name "*.deb" -o -name "*.rpm" \) | while read file; do
gh release upload ${{ inputs.tag }} "$file" --clobber
done
- name: Calc the archive signature
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG_NAME=${{ inputs.tag }}
find ./backend/target \( -name "*.deb" -o -name "*.rpm" \) | while read file; do
sha_file="$file.sha256"
if [[ ! -f "$sha_file" ]]; then
sha256sum "$file" > "$sha_file"
echo "Created checksum file for: $file"
fi
gh release upload $TAG_NAME "$sha_file" --clobber
echo "Uploaded $sha_file to release $TAG_NAME"
done
- name: Upload AppImage to Github Artifact
if: ${{ inputs.arch == 'x86_64' }}
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-linux-${{ inputs.arch }}-appimage
path: ./backend/target/**/*.AppImage
- name: Upload deb to Github Artifact
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-linux-${{ inputs.arch }}-deb
path: |
./backend/target/**/*.deb
./backend/target/**/*.deb.sha256
- name: Upload rpm to Github Artifact
uses: actions/upload-artifact@v4
with:
name: Clash.Nyanpasu-linux-${{ inputs.arch }}-rpm
path: |
./backend/target/**/*.rpm
./backend/target/**/*.rpm.sha256