🔧 build: 优化 CI/CD 构建流程,增加多架构支持

- feat: 为 Windows 构建添加 x64 和 ARM64 分离任务
- feat: 为 Linux 构建添加 ARM64 架构支持
- feat: 优化构建产物命名,包含架构标识
- chore: 更新构建相关依赖版本
- improve: Linux ARM64 使用 QEMU 交叉编译
- improve: 优化工作流任务命名和注释
This commit is contained in:
awsl1414
2025-10-15 04:24:09 +08:00
parent ecadf6ade7
commit 53468b2e3a
5 changed files with 514 additions and 632 deletions

View File

@@ -1,5 +1,5 @@
# Dev 分支推送部署预览
## 部署 Win
## 部署 Windows x64 和 ARM64 版本
name: Build Dev
on:
@@ -8,8 +8,9 @@ on:
- dev
jobs:
release:
name: Build and electron app
# Windows x64 架构
release-x64:
name: Build Electron App for Windows (x64)
runs-on: windows-latest
steps:
@@ -35,30 +36,76 @@ jobs:
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 构建 Electron App
- name: Build Electron App
run: pnpm run build:win
# 清理旧的构建产物
- name: Clean dist folder
run: |
if (Test-Path dist) {
Remove-Item -Recurse -Force dist
}
# 构建 Electron App (x64)
- name: Build Electron App for Windows x64
run: pnpm run build:win -- --x64
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 清理不必要的构建产物
# 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
- name: Cleanup Artifacts
run: npx del-cli "dist/**/*" "!dist/*.exe"
# 上传构建产物
run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
# 上传构建产物(仅上传 x64 架构的 .exe 文件)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: SPlayer-dev
path: dist
# 创建 GitHub Release
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
name: SPlayer-dev-x64
path: |
dist/*x64*.exe
dist/*x64*.exe.blockmap
# Windows ARM64 架构
release-arm64:
name: Build Electron App for Windows (ARM64)
runs-on: windows-latest
steps:
# 检出 Git 仓库
- name: Check out git repository
uses: actions/checkout@v4
# 安装 Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
tag_name: ${{ github.ref }}
name: ${{ github.ref }}-rc
body: This version is still under development, currently only provides windows version, non-developers please do not use!
draft: false
prerelease: true
files: dist/*.exe
node-version: "22.x"
# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm
# 复制环境变量文件
- name: Copy .env.example
run: |
if (-not (Test-Path .env)) {
Copy-Item .env.example .env
} else {
Write-Host ".env file already exists. Skipping the copy step."
}
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 清理旧的构建产物
- name: Clean dist folder
run: |
if (Test-Path dist) {
Remove-Item -Recurse -Force dist
}
# 构建 Electron App (ARM64)
- name: Build Electron App for Windows ARM64
run: pnpm run build:win -- --arm64
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
- name: Cleanup Artifacts
run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
# 上传构建产物(仅上传 ARM64 架构的 .exe 文件)
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: SPlayer-dev-arm64
path: |
dist/*arm64*.exe
dist/*arm64*.exe.blockmap

View File

@@ -1,5 +1,5 @@
# Release 发行版本部署
## 多端部署
## 多端部署,支持 x64 和 ARM64 架构
name: Build Release
on:
@@ -9,9 +9,9 @@ on:
workflow_dispatch:
jobs:
# Windows
build-windows:
name: Build for Windows
# Windows x64 架构
build-windows-x64:
name: Build for Windows (x64)
runs-on: windows-latest
steps:
# 检出 Git 仓库
@@ -36,29 +36,97 @@ jobs:
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 构建 Electron App
- name: Build Electron App for Windows
run: pnpm run build:win || true
# 清理旧的构建产物
- name: Clean dist folder
run: |
if (Test-Path dist) {
Remove-Item -Recurse -Force dist
}
# 构建 Electron App (x64)
- name: Build Electron App for Windows x64
run: pnpm run build:win -- --x64 || true
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建产物
- name: Upload Windows artifact
- name: Upload Windows x64 artifact
uses: actions/upload-artifact@v4
with:
name: SPlarer-Win
name: SPlayer-Win-x64
if-no-files-found: ignore
path: dist/*.*
path: |
dist/*.exe
dist/*.exe.blockmap
# 创建 GitHub Release
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: dist/*.*
files: |
dist/*.exe
dist/*.exe.blockmap
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Mac
# Windows ARM64 架构
build-windows-arm64:
name: Build for Windows (ARM64)
runs-on: windows-latest
steps:
# 检出 Git 仓库
- name: Check out git repository
uses: actions/checkout@v4
# 安装 Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm
# 复制环境变量文件
- name: Copy .env.example
run: |
if (-not (Test-Path .env)) {
Copy-Item .env.example .env
} else {
Write-Host ".env file already exists. Skipping the copy step."
}
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 清理旧的构建产物
- name: Clean dist folder
run: |
if (Test-Path dist) {
Remove-Item -Recurse -Force dist
}
# 构建 Electron App (ARM64)
- name: Build Electron App for Windows ARM64
run: pnpm run build:win -- --arm64 || true
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建产物
- name: Upload Windows ARM64 artifact
uses: actions/upload-artifact@v4
with:
name: SPlayer-Win-ARM64
if-no-files-found: ignore
path: |
dist/*.exe
dist/*.exe.blockmap
# 创建 GitHub Release
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
dist/*.exe
dist/*.exe.blockmap
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# macOS - 支持 Intel (x64) 和 Apple Silicon (ARM64)
build-macos:
name: Build for macOS
name: Build for macOS (Universal)
runs-on: macos-latest
steps:
# 检出 Git 仓库
@@ -68,7 +136,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: "22.x"
# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm
@@ -83,8 +151,11 @@ jobs:
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 构建 Electron App
- name: Build Electron App for macOS
# 清理旧的构建产物
- name: Clean dist folder
run: rm -rf dist
# 构建 Electron App同时构建 x64 和 arm64
- name: Build Electron App for macOS (x64 + ARM64)
run: pnpm run build:mac || true
shell: bash
env:
@@ -93,7 +164,7 @@ jobs:
- name: Upload macOS artifact
uses: actions/upload-artifact@v4
with:
name: SPlarer-Macos
name: SPlayer-macOS
if-no-files-found: ignore
path: dist/*.*
# 创建 GitHub Release
@@ -104,9 +175,9 @@ jobs:
files: dist/*.*
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Linux
build-linux:
name: Build for Linux
# Linux x64 架构
build-linux-x64:
name: Build for Linux (x64)
runs-on: ubuntu-22.04
steps:
# 检出 Git 仓库
@@ -116,7 +187,7 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
node-version: "22.x"
# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm
@@ -132,8 +203,6 @@ jobs:
# 安装 Snapcraft
- name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v2
with:
snapcraft_token: ${{ secrets.SNAPCRAFT_TOKEN }}
# 复制环境变量文件
- name: Copy .env.example
run: |
@@ -145,24 +214,95 @@ jobs:
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 构建 Electron App
- name: Build Electron App for Linux
run: pnpm run build:linux || true
# 清理旧的构建产物
- name: Clean dist folder
run: rm -rf dist
# 构建 Electron App (x64)
- name: Build Electron App for Linux x64
run: pnpm run build:linux -- --x64 || true
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
# 上传 Snap 包到 Snapcraft 商店
- name: Publish Snap to Snap Store
run: snapcraft upload dist/*.snap --release stable
run: |
if [ -f dist/*.snap ]; then
snapcraft upload dist/*.snap --release stable || echo "Snap upload failed or not configured"
fi
continue-on-error: true
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
# 上传构建产物
- name: Upload Linux artifact
- name: Upload Linux x64 artifact
uses: actions/upload-artifact@v4
with:
name: SPlarer-Linux
name: SPlayer-Linux-x64
if-no-files-found: ignore
path: dist/*.*
# 创建 GitHub Release
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v')
with:
files: dist/*.*
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Linux ARM64 架构
build-linux-arm64:
name: Build for Linux (ARM64)
runs-on: ubuntu-22.04
steps:
# 检出 Git 仓库
- name: Check out git repository
uses: actions/checkout@v4
# 配置 QEMU 以支持 ARM64 交叉编译
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
# 安装 Node.js
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22.x"
# 安装 pnpm
- name: Install pnpm
run: npm install -g pnpm
# 更新 Ubuntu 软件源
- name: Ubuntu Update with sudo
run: sudo apt-get update
# 安装依赖
- name: Install Build Dependencies
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 &&
sudo apt-get install --no-install-recommends -y gcc-aarch64-linux-gnu &&
sudo apt-get install --no-install-recommends -y g++-aarch64-linux-gnu
# 复制环境变量文件
- name: Copy .env.example
run: |
if [ ! -f .env ]; then
cp .env.example .env
else
echo ".env file already exists. Skipping the copy step."
fi
# 安装项目依赖
- name: Install Dependencies
run: pnpm install
# 清理旧的构建产物
- name: Clean dist folder
run: rm -rf dist
# 构建 Electron App (ARM64)
- name: Build Electron App for Linux ARM64
run: pnpm run build:linux -- --arm64 || true
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建产物
- name: Upload Linux ARM64 artifact
uses: actions/upload-artifact@v4
with:
name: SPlayer-Linux-ARM64
if-no-files-found: ignore
path: dist/*.*
# 创建 GitHub Release

View File

@@ -24,7 +24,9 @@ win:
executableName: SPlayer
# 应用程序的图标文件路径
icon: public/icons/favicon-512x512.png
# 构建类型
# Windows 平台全局文件名模板
artifactName: ${productName}-${version}-${arch}.${ext}
# 构建类型(架构由命令行参数 --x64 或 --arm64 指定)
target:
# 安装版
- nsis
@@ -35,7 +37,7 @@ nsis:
# 是否一键式安装
oneClick: false
# 安装程序的生成名称
artifactName: ${productName}-${version}-setup.${ext}
artifactName: ${productName}-${version}-${arch}-setup.${ext}
# 创建的桌面快捷方式名称
shortcutName: ${productName}
# 卸载时显示的名称
@@ -50,6 +52,10 @@ nsis:
installerIcon: public/icons/favicon.ico
# 卸载命令图标
uninstallerIcon: public/icons/favicon.ico
# Portable 便携版配置
portable:
# 便携版文件名
artifactName: ${productName}-${version}-${arch}-portable.${ext}
# macOS 平台配置
mac:
# 可执行文件名
@@ -58,12 +64,14 @@ mac:
icon: public/icons/favicon-512x512.png
# 权限继承的文件路径
entitlementsInherit: build/entitlements.mac.plist
# macOS 平台全局文件名模板
artifactName: ${name}-${version}-${arch}.${ext}
# 扩展信息,如权限描述
extendInfo:
- NSCameraUsageDescription: Application requests access to the device's camera.
- NSMicrophoneUsageDescription: Application requests access to the device's microphone.
- NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
- NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
NSCameraUsageDescription: Application requests access to the device's camera.
NSMicrophoneUsageDescription: Application requests access to the device's microphone.
NSDocumentsFolderUsageDescription: Application requests access to the user's Documents folder.
NSDownloadsFolderUsageDescription: Application requests access to the user's Downloads folder.
# 是否启用应用程序的 Notarization苹果的安全审核
notarize: false
darkModeSupport: true
@@ -80,29 +88,49 @@ mac:
# macOS 平台的 DMG 配置
dmg:
# DMG 文件的生成名称
artifactName: ${name}-${version}.${ext}
artifactName: ${name}-${version}-${arch}.${ext}
# Linux 平台配置
linux:
# 可执行文件名
executableName: splayer
# 应用程序的图标文件路径
icon: public/icons/favicon-512x512.png
# 构建类型
# Linux 所有格式的统一文件名模板
artifactName: ${name}-${version}-${arch}.${ext}
# 构建类型 - 支持 x64 和 ARM64 架构
target:
- pacman
- AppImage
- deb
- rpm
- snap
- tar.gz
- target: pacman
arch:
- x64
- arm64
- target: AppImage
arch:
- x64
- arm64
- target: deb
arch:
- x64
- arm64
- target: rpm
arch:
- x64
- arm64
# Snap 仅支持 x64 架构(无法在 x64 主机上交叉编译 ARM64
- target: snap
arch:
- x64
- target: tar.gz
arch:
- x64
- arm64
# 维护者信息
maintainer: imsyy.top
# 应用程序类别
category: Audio;Music
# AppImage 配置
# AppImage 特定配置
appImage:
# AppImage 文件的生成名称
artifactName: ${name}-${version}.${ext}
# AppImage 文件的生成名称
artifactName: ${name}-${version}-${arch}.${ext}
# 是否在构建之前重新编译原生模块
npmRebuild: false
# 自动更新的配置

View File

@@ -116,8 +116,8 @@
},
"pnpm": {
"overrides": {
"dmg-builder": "25.1.8",
"electron-builder-squirrel-windows": "25.1.8"
"dmg-builder": "26.0.12",
"electron-builder-squirrel-windows": "26.0.12"
},
"onlyBuiltDependencies": [
"@applemusic-like-lyrics/lyric",

787
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff