11# Dev 分支推送部署预览
2- # # 部署 Windows
32name : Build Dev
43
54on :
1918 - " .env.example"
2019 - " Dockerfile"
2120 - " docker-compose.yml"
21+ workflow_dispatch :
2222
2323env :
2424 NODE_VERSION : 22.x
2525 PNPM_VERSION : 8
2626
2727jobs :
28- # Windows x64 架构
29- build-win :
30- name : Build Electron App for Windows
31- runs-on : windows-latest
32-
28+ # ===================================================================
29+ # 并行构建所有平台和架构
30+ # ===================================================================
31+ build :
32+ name : Build on ${{ matrix.os }}
33+ runs-on : ${{ matrix.os }}
34+ strategy :
35+ # 矩阵策略
36+ # 即使一个矩阵任务失败,其他任务也会继续运行
37+ fail-fast : false
38+ matrix :
39+ os : [macos-latest, windows-latest, ubuntu-latest]
40+ # 开始步骤
3341 steps :
3442 # 检出 Git 仓库
3543 - name : Check out git repository
@@ -40,41 +48,98 @@ jobs:
4048 with :
4149 version : ${{ env.PNPM_VERSION }}
4250 # 安装 Node.js
43- - name : Install Node.js
51+ - name : Setup Node.js
4452 uses : actions/setup-node@v6
4553 with :
4654 node-version : ${{ env.NODE_VERSION }}
4755 cache : " pnpm"
56+ # 清理旧的构建产物
57+ - name : Clean workspace on Windows
58+ if : runner.os == 'Windows'
59+ run : |
60+ Write-Host "🧹 Cleaning workspace, node_modules, and Electron caches..."
61+ if (Test-Path dist) { Remove-Item -Recurse -Force dist }
62+ if (Test-Path out) { Remove-Item -Recurse -Force out }
63+ if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules }
64+
65+ if (Test-Path "$env:LOCALAPPDATA\electron-builder") {
66+ Remove-Item "$env:LOCALAPPDATA\electron-builder" -Recurse -Force -ErrorAction SilentlyContinue
67+ }
68+ if (Test-Path "$env:LOCALAPPDATA\electron") {
69+ Remove-Item "$env:LOCALAPPDATA\electron" -Recurse -Force -ErrorAction SilentlyContinue
70+ }
71+ - name : Clean workspace on macOS & Linux
72+ if : runner.os == 'macOS' || runner.os == 'Linux'
73+ run : |
74+ echo "🧹 Cleaning workspace, node_modules, and Electron caches..."
75+ rm -rf dist out node_modules ~/.cache/electron-builder ~/.cache/electron
76+ # 安装项目依赖
77+ - name : Install dependencies
78+ run : pnpm install
4879 # 复制环境变量文件
49- - name : Copy .env.example
80+ - name : Copy .env file on Windows
81+ if : runner.os == 'Windows'
5082 run : |
5183 if (-not (Test-Path .env)) {
5284 Copy-Item .env.example .env
5385 } else {
5486 Write-Host ".env file already exists. Skipping the copy step."
5587 }
56- # 安装项目依赖
57- - name : Install Dependencies
58- run : pnpm install
59- # 清理旧的构建产物
60- - name : Clean dist folder
88+ - name : Copy .env file on macOS & Linux
89+ if : runner.os == 'macOS' || runner.os == 'Linux'
6190 run : |
62- if (Test-Path dist) {
63- Remove-Item -Recurse -Force dist
64- }
65- # 构建 Electron App (x64)
66- - name : Build Electron App for Windows x64
67- # 仅 x64
68- run : pnpm run build:win -- --x64
91+ if [ ! -f .env ]; then
92+ cp .env.example .env
93+ else
94+ echo ".env file already exists. Skipping the copy step."
95+ fi
96+ # 更新 Ubuntu 软件源
97+ - name : Ubuntu Update with sudo
98+ if : runner.os == 'Linux'
99+ run : sudo apt-get update
100+ # 安装依赖
101+ - name : Install RPM & Pacman
102+ if : runner.os == 'Linux'
103+ run : |
104+ sudo apt-get install --no-install-recommends -y rpm &&
105+ sudo apt-get install --no-install-recommends -y libarchive-tools &&
106+ sudo apt-get install --no-install-recommends -y libopenjp2-tools
107+ # 构建 Electron App
108+ - name : Build Windows x64 & ARM64 App
109+ if : runner.os == 'Windows'
110+ run : pnpm build:win -- --x64 --arm64 || true
69111 env :
70112 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
71- # 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
72- - name : Cleanup Artifacts
73- run : npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
74- # 上传构建产物(仅上传 x64 架构的 .exe 文件)
75- - name : Upload artifacts
76- uses : actions/upload-artifact@v4
77- with :
78- name : SPlayer-dev
79- path : |
80- dist/**.exe
113+ - name : Build macOS Universal App
114+ if : runner.os == 'macOS'
115+ run : pnpm build:mac -- --x64 --arm64 || true
116+ shell : bash
117+ env :
118+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119+ - name : Build Linux x64 & ARM64 App
120+ if : runner.os == 'Linux'
121+ run : pnpm build:linux -- --x64 --arm64 || true
122+ shell : bash
123+ env :
124+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
125+
126+ # 分别上传
127+ - { name: Upload Artifacts - Windows Setup x64, if: runner.os == 'Windows', uses: actions/upload-artifact@v4, with: { name: SPlayer-Windows-setup-x64, path: dist/*-x64-setup.exe } }
128+ - { name: Upload Artifacts - Windows Setup arm64, if: runner.os == 'Windows', uses: actions/upload-artifact@v4, with: { name: SPlayer-Windows-setup-arm64, path: dist/*-arm64-setup.exe } }
129+ - { name: Upload Artifacts - Windows Portable x64, if: runner.os == 'Windows', uses: actions/upload-artifact@v4, with: { name: SPlayer-Windows-portable-x64, path: dist/*-x64-portable.exe } }
130+ - { name: Upload Artifacts - Windows Portable arm64, if: runner.os == 'Windows', uses: actions/upload-artifact@v4, with: { name: SPlayer-Windows-portable-arm64, path: dist/*-arm64-portable.exe } }
131+ - { name: Upload Artifacts - macOS DMG x64, if: runner.os == 'macOS', uses: actions/upload-artifact@v4, with: { name: SPlayer-macOS-dmg-x64, path: dist/*-x64.dmg } }
132+ - { name: Upload Artifacts - macOS DMG arm64, if: runner.os == 'macOS', uses: actions/upload-artifact@v4, with: { name: SPlayer-macOS-dmg-arm64, path: dist/*-arm64.dmg } }
133+ - { name: Upload Artifacts - macOS Zip x64, if: runner.os == 'macOS', uses: actions/upload-artifact@v4, with: { name: SPlayer-macOS-zip-x64, path: dist/*-x64.zip } }
134+ - { name: Upload Artifacts - macOS Zip arm64 , if: runner.os == 'macOS', uses: actions/upload-artifact@v4, with: { name: SPlayer-macOS-zip-arm64, path: dist/*-arm64.zip } }
135+ - { name: Upload Artifacts - Linux AppImage x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-appimage-x64, path: dist/*-x86_64.AppImage } }
136+ - { name: Upload Artifacts - Linux AppImage arm64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-appimage-arm64, path: dist/*-arm64.AppImage } }
137+ - { name: Upload Artifacts - Linux Pacman x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-pacman-x64, path: dist/*-x64.pacman } }
138+ - { name: Upload Artifacts - Linux Pacman arm64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-pacman-arm64, path: dist/*-aarch64.pacman } }
139+ - { name: Upload Artifacts - Linux DEB x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-deb-x64, path: dist/*-amd64.deb } }
140+ - { name: Upload Artifacts - Linux DEB arm64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-deb-arm64, path: dist/*-arm64.deb } }
141+ - { name: Upload Artifacts - Linux RPM x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-rpm-x64, path: dist/*-x86_64.rpm } }
142+ - { name: Upload Artifacts - Linux RPM arm64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-rpm-arm64, path: dist/*-aarch64.rpm } }
143+ - { name: Upload Artifacts - Linux Tar x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-tar-x64, path: dist/*-x64.tar.gz } }
144+ - { name: Upload Artifacts - Linux Tar arm64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-tar-arm64, path: dist/*-arm64.tar.gz } }
145+ - { name: Upload Artifacts - Linux Snap x64, if: runner.os == 'Linux', uses: actions/upload-artifact@v4, with: { name: SPlayer-Linux-snap-x64, path: dist/*-amd64.snap } }
0 commit comments