-
Notifications
You must be signed in to change notification settings - Fork 1.2k
145 lines (140 loc) · 7.74 KB
/
dev.yml
File metadata and controls
145 lines (140 loc) · 7.74 KB
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
# Dev 分支推送部署预览
name: Build Dev
on:
push:
branches:
- dev
paths:
- "src/**"
- "web/**"
- "electron/**"
- "public/**"
- "package.json"
- "pnpm-lock.yaml"
- "electron-builder.config.ts"
- "electron.vite.config.ts"
- "tsconfig*.json"
- ".env.example"
- "Dockerfile"
- "docker-compose.yml"
workflow_dispatch:
env:
NODE_VERSION: 22.x
PNPM_VERSION: 8
jobs:
# ===================================================================
# 并行构建所有平台和架构
# ===================================================================
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# 矩阵策略
# 即使一个矩阵任务失败,其他任务也会继续运行
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
# 开始步骤
steps:
# 检出 Git 仓库
- name: Check out git repository
uses: actions/checkout@v4
# 设置 pnpm 版本
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: ${{ env.PNPM_VERSION }}
# 安装 Node.js
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: "pnpm"
# 清理旧的构建产物
- name: Clean workspace on Windows
if: runner.os == 'Windows'
run: |
Write-Host "🧹 Cleaning workspace, node_modules, and Electron caches..."
if (Test-Path dist) { Remove-Item -Recurse -Force dist }
if (Test-Path out) { Remove-Item -Recurse -Force out }
if (Test-Path node_modules) { Remove-Item -Recurse -Force node_modules }
if (Test-Path "$env:LOCALAPPDATA\electron-builder") {
Remove-Item "$env:LOCALAPPDATA\electron-builder" -Recurse -Force -ErrorAction SilentlyContinue
}
if (Test-Path "$env:LOCALAPPDATA\electron") {
Remove-Item "$env:LOCALAPPDATA\electron" -Recurse -Force -ErrorAction SilentlyContinue
}
- name: Clean workspace on macOS & Linux
if: runner.os == 'macOS' || runner.os == 'Linux'
run: |
echo "🧹 Cleaning workspace, node_modules, and Electron caches..."
rm -rf dist out node_modules ~/.cache/electron-builder ~/.cache/electron
# 安装项目依赖
- name: Install dependencies
run: pnpm install
# 复制环境变量文件
- name: Copy .env file on Windows
if: runner.os == 'Windows'
run: |
if (-not (Test-Path .env)) {
Copy-Item .env.example .env
} else {
Write-Host ".env file already exists. Skipping the copy step."
}
- name: Copy .env file on macOS & Linux
if: runner.os == 'macOS' || runner.os == 'Linux'
run: |
if [ ! -f .env ]; then
cp .env.example .env
else
echo ".env file already exists. Skipping the copy step."
fi
# 更新 Ubuntu 软件源
- name: Ubuntu Update with sudo
if: runner.os == 'Linux'
run: sudo apt-get update
# 安装依赖
- name: Install RPM & Pacman
if: runner.os == 'Linux'
run: |
sudo apt-get install --no-install-recommends -y rpm &&
sudo apt-get install --no-install-recommends -y libarchive-tools &&
sudo apt-get install --no-install-recommends -y libopenjp2-tools
# 构建 Electron App
- name: Build Windows x64 & ARM64 App
if: runner.os == 'Windows'
run: pnpm build:win -- --x64 --arm64
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build macOS Universal App
if: runner.os == 'macOS'
run: pnpm build:mac -- --x64 --arm64
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build Linux x64 & ARM64 App
if: runner.os == 'Linux'
run: pnpm build:linux -- --x64 --arm64
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# 分别上传
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }
- { 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 } }