99env :
1010 NODE_VERSION : 22.x
1111 PNPM_VERSION : 8
12+ SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
1213
1314jobs :
1415 # ===================================================================
@@ -38,23 +39,46 @@ jobs:
3839 with :
3940 node-version : ${{ env.NODE_VERSION }}
4041 cache : " pnpm"
42+ # 清理旧的构建产物
43+ - name : Clean workspace on Windows
44+ if : runner.os == 'Windows'
45+ run : |
46+ Write-Host "🧹 Cleaning workspace, node_modules, and Electron caches..."
47+ if (Test-Path dist) { Remove-Item -Recurse -Force dist }
48+ if (Test-Path out) { Remove-Item -Recurse -Force out }
49+ if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules }
50+
51+ if (Test-Path "$env:LOCALAPPDATA\electron-builder") {
52+ Remove-Item "$env:LOCALAPPDATA\electron-builder" -Recurse -Force -ErrorAction SilentlyContinue
53+ }
54+ if (Test-Path "$env:LOCALAPPDATA\electron") {
55+ Remove-Item "$env:LOCALAPPDATA\electron" -Recurse -Force -ErrorAction SilentlyContinue
56+ }
57+ - name : Clean workspace on macOS & Linux
58+ if : runner.os == 'macOS' || runner.os == 'Linux'
59+ run : |
60+ echo "🧹 Cleaning workspace, node_modules, and Electron caches..."
61+ rm -rf dist out node_modules ~/.cache/electron-builder ~/.cache/electron
4162 # 安装项目依赖
4263 - name : Install dependencies
4364 run : pnpm install
4465 # 复制环境变量文件
4566 - name : Copy .env file on Windows
4667 if : runner.os == 'Windows'
47- run : Copy-Item .env.example .env -ErrorAction SilentlyContinue
68+ run : |
69+ if (-not (Test-Path .env)) {
70+ Copy-Item .env.example .env
71+ } else {
72+ Write-Host ".env file already exists. Skipping the copy step."
73+ }
4874 - name : Copy .env file on macOS & Linux
4975 if : runner.os == 'macOS' || runner.os == 'Linux'
50- run : cp -n .env.example .env
51- # 清理旧的构建产物
52- - name : Clean dist folder on Windows
53- if : runner.os == 'Windows'
54- run : if (Test-Path dist) { Remove-Item -Recurse -Force dist }
55- - name : Clean dist folder on macOS & Linux
56- if : runner.os == 'macOS' || runner.os == 'Linux'
57- run : rm -rf dist
76+ run : |
77+ if [ ! -f .env ]; then
78+ cp .env.example .env
79+ else
80+ echo ".env file already exists. Skipping the copy step."
81+ fi
5882 # 更新 Ubuntu 软件源
5983 - name : Ubuntu Update with sudo
6084 if : runner.os == 'Linux'
@@ -73,35 +97,34 @@ jobs:
7397 with :
7498 SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
7599 # 构建 Electron App
76- - name : Build macOS Universal App
77- if : runner.os == 'macOS'
78- run : pnpm run build:mac -- --universal || true
79- env :
80- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
81100 - name : Build Windows x64 & ARM64 App
82101 if : runner.os == 'Windows'
83- run : pnpm run build:win -- --x64 --arm64 || true
102+ run : pnpm build:win || true
103+ env :
104+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105+ - name : Build macOS Universal App
106+ if : runner.os == 'macOS'
107+ run : pnpm build:mac || true
108+ shell : bash
84109 env :
85110 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
86111 - name : Build Linux x64 & ARM64 App
87112 if : runner.os == 'Linux'
88- run : pnpm run build:linux -- --x64 --arm64 || true
113+ run : pnpm build:linux || true
114+ shell : bash
89115 env :
90116 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
91- SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
92117 # 上传 Snap 包到 Snapcraft 商店
93118 - name : Publish Snap to Snap Store
94119 if : runner.os == 'Linux'
95120 run : snapcraft upload dist/*.snap --release stable
96121 continue-on-error : true
97- env :
98- SNAPCRAFT_STORE_CREDENTIALS : ${{ secrets.SNAPCRAFT_TOKEN }}
99122 # 合并所有构建
100123 - name : Upload Artifact
101124 uses : actions/upload-artifact@v4
102125 with :
103126 name : SPlayer-${{ runner.os }}
104- path : dist/
127+ path : dist/*.*
105128
106129 # ===================================================================
107130 # 收集并发布 Release
@@ -130,3 +153,17 @@ jobs:
130153 draft : false
131154 # 发布为预发布
132155 prerelease : false
156+ # 全部上传
157+ files : |
158+ !artifacts/**/*-unpacked/**
159+ artifacts/**/*.exe
160+ artifacts/**/*.dmg
161+ artifacts/**/*.zip
162+ artifacts/**/*.AppImage
163+ artifacts/**/*.deb
164+ artifacts/**/*.rpm
165+ artifacts/**/*.pacman
166+ artifacts/**/*.snap
167+ artifacts/**/*.tar.gz
168+ artifacts/**/*.yml
169+ artifacts/**/*.blockmap
0 commit comments