@@ -28,33 +28,53 @@ jobs:
2828 # 并行构建所有平台和架构
2929 # ===================================================================
3030 build :
31- name : Build on ${{ matrix.os }}
32- runs-on : ${{ matrix.os }}
31+ name : Build on ${{ matrix.name }}
32+ runs-on : ${{ matrix.runner }}
3333 strategy :
3434 # 矩阵策略
3535 # 即使一个矩阵任务失败,其他任务也会继续运行
3636 fail-fast : false
3737 matrix :
38- os : [macos-latest, windows-latest, ubuntu-latest]
38+ include :
39+ - name : Windows x64
40+ runner : windows-latest
41+ target : windows-x64
42+ - name : Windows arm64
43+ runner : windows-11-arm
44+ target : windows-arm64
45+ - name : macOS x64
46+ runner : macos-15-intel
47+ target : macos-x64
48+ - name : macOS arm64
49+ runner : macos-latest
50+ target : macos-arm64
51+ - name : Linux x64
52+ runner : ubuntu-latest
53+ target : linux-x64
54+ - name : Linux arm64
55+ runner : ubuntu-24.04-arm
56+ target : linux-arm64
3957 # 开始步骤
4058 steps :
4159 # 检出 Git 仓库
4260 - name : Check out git repository
43- uses : actions/checkout@v4
61+ uses : actions/checkout@v6
4462 # 设置 pnpm
4563 - name : Setup pnpm
46- uses : pnpm/action-setup@v3
64+ uses : pnpm/action-setup@v5
4765 # 安装 Node.js
4866 - name : Setup Node.js
4967 uses : actions/setup-node@v6
5068 with :
5169 node-version : ${{ env.NODE_VERSION }}
70+ # 设置 Rust
5271 - name : Setup Rust toolchain
5372 uses : dtolnay/rust-toolchain@stable
5473 with :
5574 toolchain : stable
5675 - name : Rust Cache
5776 uses : Swatinem/rust-cache@v2
77+
5878 # 清理旧的构建产物
5979 - name : Clean workspace on Windows
6080 if : runner.os == 'Windows'
7999 run : |
80100 echo "🧹 Cleaning workspace, node_modules, Electron caches, and pnpm store..."
81101 rm -rf dist out node_modules ~/.cache/electron-builder ~/.cache/electron ~/.pnpm-store
102+
103+ # 更新 Ubuntu 软件源并安装依赖
104+ - name : Update and Install Ubuntu Dependencies
105+ if : runner.os == 'Linux'
106+ run : |
107+ sudo apt-get update
108+ sudo apt-get install --no-install-recommends -y rpm libarchive-tools libopenjp2-tools
109+
82110 # macOS 上安装 LLVM 以支持 Wasm 编译
83111 - name : Install LLVM on macOS
84112 if : runner.os == 'macOS'
88116 run : |
89117 echo "CC=$(brew --prefix llvm)/bin/clang" >> $GITHUB_ENV
90118 echo "AR=$(brew --prefix llvm)/bin/llvm-ar" >> $GITHUB_ENV
91- # 安装项目依赖
92- - name : Install dependencies
93- run : pnpm install
119+
94120 # 复制环境变量文件
95121 - name : Copy .env file on Windows
96122 if : runner.os == 'Windows'
@@ -108,143 +134,149 @@ jobs:
108134 else
109135 echo ".env file already exists. Skipping the copy step."
110136 fi
111- # 更新 Ubuntu 软件源
112- - name : Ubuntu Update with sudo
113- if : runner.os == 'Linux'
114- run : sudo apt-get update
115- # 安装依赖
116- - name : Install RPM & Pacman
117- if : runner.os == 'Linux'
118- run : |
119- sudo apt-get install --no-install-recommends -y rpm &&
120- sudo apt-get install --no-install-recommends -y libarchive-tools &&
121- sudo apt-get install --no-install-recommends -y libopenjp2-tools
137+
138+ # 安装项目依赖
139+ - name : Install dependencies
140+ run : pnpm install
141+
122142 # 构建 Electron App
123- - name : Build Windows x64 & ARM64 App
124- if : runner.os == 'Windows'
125- run : pnpm build:win -- --x64 --arm64
126- env :
127- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
128- - name : Build macOS Universal App
129- if : runner.os == 'macOS'
130- run : pnpm build:mac -- --x64 --arm64
131- shell : bash
143+ - name : Build
132144 env :
133145 CSC_IDENTITY_AUTO_DISCOVERY : false
134146 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
135- - name : Build Linux x64 & ARM64 App
136- if : runner.os == 'Linux'
137- run : pnpm build:linux -- --x64 --arm64
138147 shell : bash
139- env :
140- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
148+ run : |
149+ case "${{ matrix.target }}" in
150+ windows-x64)
151+ pnpm build:win -- --x64
152+ ;;
153+ windows-arm64)
154+ pnpm build:win -- --arm64
155+ ;;
156+ macos-x64)
157+ pnpm build:mac -- --x64
158+ ;;
159+ macos-arm64)
160+ pnpm build:mac -- --arm64
161+ ;;
162+ linux-x64)
163+ pnpm build:linux -- --x64
164+ ;;
165+ linux-arm64)
166+ pnpm build:linux -- --arm64
167+ ;;
168+ *)
169+ echo "Unsupported target: ${{ matrix.target }}"
170+ exit 1
171+ ;;
172+ esac
141173
142174 # 分别上传
143175 - {
144176 name : Upload Artifacts - Windows Setup x64,
145- if : runner.os == 'Windows ',
146- uses : actions/upload-artifact@v4 ,
177+ if : matrix.target == 'windows-x64 ',
178+ uses : actions/upload-artifact@v7 ,
147179 with : { name: SPlayer-Windows-setup-x64, path: dist/*-x64-setup.exe },
148180 }
149181 - {
150182 name : Upload Artifacts - Windows Setup arm64,
151- if : runner.os == 'Windows ',
152- uses : actions/upload-artifact@v4 ,
183+ if : matrix.target == 'windows-arm64 ',
184+ uses : actions/upload-artifact@v7 ,
153185 with : { name: SPlayer-Windows-setup-arm64, path: dist/*-arm64-setup.exe },
154186 }
155187 - {
156188 name : Upload Artifacts - Windows Portable x64,
157- if : runner.os == 'Windows ',
158- uses : actions/upload-artifact@v4 ,
189+ if : matrix.target == 'windows-x64 ',
190+ uses : actions/upload-artifact@v7 ,
159191 with : { name: SPlayer-Windows-portable-x64, path: dist/*-x64-portable.exe },
160192 }
161193 - {
162194 name : Upload Artifacts - Windows Portable arm64,
163- if : runner.os == 'Windows ',
164- uses : actions/upload-artifact@v4 ,
195+ if : matrix.target == 'windows-arm64 ',
196+ uses : actions/upload-artifact@v7 ,
165197 with : { name: SPlayer-Windows-portable-arm64, path: dist/*-arm64-portable.exe },
166198 }
167199 - {
168200 name : Upload Artifacts - macOS DMG x64,
169- if : runner.os == 'macOS ',
170- uses : actions/upload-artifact@v4 ,
201+ if : matrix.target == 'macos-x64 ',
202+ uses : actions/upload-artifact@v7 ,
171203 with : { name: SPlayer-macOS-dmg-x64, path: dist/*-x64.dmg },
172204 }
173205 - {
174206 name : Upload Artifacts - macOS DMG arm64,
175- if : runner.os == 'macOS ',
176- uses : actions/upload-artifact@v4 ,
207+ if : matrix.target == 'macos-arm64 ',
208+ uses : actions/upload-artifact@v7 ,
177209 with : { name: SPlayer-macOS-dmg-arm64, path: dist/*-arm64.dmg },
178210 }
179211 - {
180212 name : Upload Artifacts - macOS Zip x64,
181- if : runner.os == 'macOS ',
182- uses : actions/upload-artifact@v4 ,
213+ if : matrix.target == 'macos-x64 ',
214+ uses : actions/upload-artifact@v7 ,
183215 with : { name: SPlayer-macOS-zip-x64, path: dist/*-x64.zip },
184216 }
185217 - {
186218 name : Upload Artifacts - macOS Zip arm64,
187- if : runner.os == 'macOS ',
188- uses : actions/upload-artifact@v4 ,
219+ if : matrix.target == 'macos-arm64 ',
220+ uses : actions/upload-artifact@v7 ,
189221 with : { name: SPlayer-macOS-zip-arm64, path: dist/*-arm64.zip },
190222 }
191223 - {
192224 name : Upload Artifacts - Linux AppImage x64,
193- if : runner.os == 'Linux ',
194- uses : actions/upload-artifact@v4 ,
225+ if : matrix.target == 'linux-x64 ',
226+ uses : actions/upload-artifact@v7 ,
195227 with : { name: SPlayer-Linux-appimage-x64, path: dist/*-x86_64.AppImage },
196228 }
197229 - {
198230 name : Upload Artifacts - Linux AppImage arm64,
199- if : runner.os == 'Linux ',
200- uses : actions/upload-artifact@v4 ,
231+ if : matrix.target == 'linux-arm64 ',
232+ uses : actions/upload-artifact@v7 ,
201233 with : { name: SPlayer-Linux-appimage-arm64, path: dist/*-arm64.AppImage },
202234 }
203235 - {
204236 name : Upload Artifacts - Linux Pacman x64,
205- if : runner.os == 'Linux ',
206- uses : actions/upload-artifact@v4 ,
237+ if : matrix.target == 'linux-x64 ',
238+ uses : actions/upload-artifact@v7 ,
207239 with : { name: SPlayer-Linux-pacman-x64, path: dist/*-x64.pacman },
208240 }
209241 - {
210242 name : Upload Artifacts - Linux Pacman arm64,
211- if : runner.os == 'Linux ',
212- uses : actions/upload-artifact@v4 ,
243+ if : matrix.target == 'linux-arm64 ',
244+ uses : actions/upload-artifact@v7 ,
213245 with : { name: SPlayer-Linux-pacman-arm64, path: dist/*-aarch64.pacman },
214246 }
215247 - {
216248 name : Upload Artifacts - Linux DEB x64,
217- if : runner.os == 'Linux ',
218- uses : actions/upload-artifact@v4 ,
249+ if : matrix.target == 'linux-x64 ',
250+ uses : actions/upload-artifact@v7 ,
219251 with : { name: SPlayer-Linux-deb-x64, path: dist/*-amd64.deb },
220252 }
221253 - {
222254 name : Upload Artifacts - Linux DEB arm64,
223- if : runner.os == 'Linux ',
224- uses : actions/upload-artifact@v4 ,
255+ if : matrix.target == 'linux-arm64 ',
256+ uses : actions/upload-artifact@v7 ,
225257 with : { name: SPlayer-Linux-deb-arm64, path: dist/*-arm64.deb },
226258 }
227259 - {
228260 name : Upload Artifacts - Linux RPM x64,
229- if : runner.os == 'Linux ',
230- uses : actions/upload-artifact@v4 ,
261+ if : matrix.target == 'linux-x64 ',
262+ uses : actions/upload-artifact@v7 ,
231263 with : { name: SPlayer-Linux-rpm-x64, path: dist/*-x86_64.rpm },
232264 }
233265 - {
234266 name : Upload Artifacts - Linux RPM arm64,
235- if : runner.os == 'Linux ',
236- uses : actions/upload-artifact@v4 ,
267+ if : matrix.target == 'linux-arm64 ',
268+ uses : actions/upload-artifact@v7 ,
237269 with : { name: SPlayer-Linux-rpm-arm64, path: dist/*-aarch64.rpm },
238270 }
239271 - {
240272 name : Upload Artifacts - Linux Tar x64,
241- if : runner.os == 'Linux ',
242- uses : actions/upload-artifact@v4 ,
273+ if : matrix.target == 'linux-x64 ',
274+ uses : actions/upload-artifact@v7 ,
243275 with : { name: SPlayer-Linux-tar-x64, path: dist/*-x64.tar.gz },
244276 }
245277 - {
246278 name : Upload Artifacts - Linux Tar arm64,
247- if : runner.os == 'Linux ',
248- uses : actions/upload-artifact@v4 ,
279+ if : matrix.target == 'linux-arm64 ',
280+ uses : actions/upload-artifact@v7 ,
249281 with : { name: SPlayer-Linux-tar-arm64, path: dist/*-arm64.tar.gz },
250282 }
0 commit comments