🔧 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 分支推送部署预览 # Dev 分支推送部署预览
## 部署 Win ## 部署 Windows x64 和 ARM64 版本
name: Build Dev name: Build Dev
on: on:
@@ -8,8 +8,9 @@ on:
- dev - dev
jobs: jobs:
release: # Windows x64 架构
name: Build and electron app release-x64:
name: Build Electron App for Windows (x64)
runs-on: windows-latest runs-on: windows-latest
steps: steps:
@@ -35,30 +36,76 @@ jobs:
# 安装项目依赖 # 安装项目依赖
- name: Install Dependencies - name: Install Dependencies
run: pnpm install run: pnpm install
# 构建 Electron App # 清理旧的构建产物
- name: Build Electron App - name: Clean dist folder
run: pnpm run build:win 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: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 清理不必要的构建产物 # 清理不必要的构建产物(保留 .exe 和 .blockmap 文件)
- name: Cleanup Artifacts - name: Cleanup Artifacts
run: npx del-cli "dist/**/*" "!dist/*.exe" run: npx del-cli "dist/**/*.yaml" "dist/**/*.yml"
# 上传构建产物 # 上传构建产物(仅上传 x64 架构的 .exe 文件)
- name: Upload artifacts - name: Upload artifacts
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: SPlayer-dev name: SPlayer-dev-x64
path: dist path: |
# 创建 GitHub Release dist/*x64*.exe
- name: Release dist/*x64*.exe.blockmap
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v') # 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: with:
tag_name: ${{ github.ref }} node-version: "22.x"
name: ${{ github.ref }}-rc # 安装 pnpm
body: This version is still under development, currently only provides windows version, non-developers please do not use! - name: Install pnpm
draft: false run: npm install -g pnpm
prerelease: true # 复制环境变量文件
files: dist/*.exe - 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: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} 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 发行版本部署 # Release 发行版本部署
## 多端部署 ## 多端部署,支持 x64 和 ARM64 架构
name: Build Release name: Build Release
on: on:
@@ -9,9 +9,9 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
# Windows # Windows x64 架构
build-windows: build-windows-x64:
name: Build for Windows name: Build for Windows (x64)
runs-on: windows-latest runs-on: windows-latest
steps: steps:
# 检出 Git 仓库 # 检出 Git 仓库
@@ -36,29 +36,97 @@ jobs:
# 安装项目依赖 # 安装项目依赖
- name: Install Dependencies - name: Install Dependencies
run: pnpm install run: pnpm install
# 构建 Electron App # 清理旧的构建产物
- name: Build Electron App for Windows - name: Clean dist folder
run: pnpm run build:win || true 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: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# 上传构建产物 # 上传构建产物
- name: Upload Windows artifact - name: Upload Windows x64 artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: SPlarer-Win name: SPlayer-Win-x64
if-no-files-found: ignore if-no-files-found: ignore
path: dist/*.* path: |
dist/*.exe
dist/*.exe.blockmap
# 创建 GitHub Release # 创建 GitHub Release
- name: Release - name: Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/v') if: startsWith(github.ref, 'refs/tags/v')
with: with:
files: dist/*.* files: |
dist/*.exe
dist/*.exe.blockmap
env: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} 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: build-macos:
name: Build for macOS name: Build for macOS (Universal)
runs-on: macos-latest runs-on: macos-latest
steps: steps:
# 检出 Git 仓库 # 检出 Git 仓库
@@ -68,7 +136,7 @@ jobs:
- name: Install Node.js - name: Install Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: "20.x" node-version: "22.x"
# 安装 pnpm # 安装 pnpm
- name: Install pnpm - name: Install pnpm
run: npm install -g pnpm run: npm install -g pnpm
@@ -83,8 +151,11 @@ jobs:
# 安装项目依赖 # 安装项目依赖
- name: Install Dependencies - name: Install Dependencies
run: pnpm install 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 run: pnpm run build:mac || true
shell: bash shell: bash
env: env:
@@ -93,7 +164,7 @@ jobs:
- name: Upload macOS artifact - name: Upload macOS artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: SPlarer-Macos name: SPlayer-macOS
if-no-files-found: ignore if-no-files-found: ignore
path: dist/*.* path: dist/*.*
# 创建 GitHub Release # 创建 GitHub Release
@@ -104,9 +175,9 @@ jobs:
files: dist/*.* files: dist/*.*
env: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
# Linux # Linux x64 架构
build-linux: build-linux-x64:
name: Build for Linux name: Build for Linux (x64)
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
# 检出 Git 仓库 # 检出 Git 仓库
@@ -116,7 +187,7 @@ jobs:
- name: Install Node.js - name: Install Node.js
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: "20.x" node-version: "22.x"
# 安装 pnpm # 安装 pnpm
- name: Install pnpm - name: Install pnpm
run: npm install -g pnpm run: npm install -g pnpm
@@ -132,8 +203,6 @@ jobs:
# 安装 Snapcraft # 安装 Snapcraft
- name: Install Snapcraft - name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v2 uses: samuelmeuli/action-snapcraft@v2
with:
snapcraft_token: ${{ secrets.SNAPCRAFT_TOKEN }}
# 复制环境变量文件 # 复制环境变量文件
- name: Copy .env.example - name: Copy .env.example
run: | run: |
@@ -145,24 +214,95 @@ jobs:
# 安装项目依赖 # 安装项目依赖
- name: Install Dependencies - name: Install Dependencies
run: pnpm install run: pnpm install
# 构建 Electron App # 清理旧的构建产物
- name: Build Electron App for Linux - name: Clean dist folder
run: pnpm run build:linux || true run: rm -rf dist
# 构建 Electron App (x64)
- name: Build Electron App for Linux x64
run: pnpm run build:linux -- --x64 || true
shell: bash shell: bash
env: env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }}
# 上传 Snap 包到 Snapcraft 商店 # 上传 Snap 包到 Snapcraft 商店
- name: Publish Snap to Snap Store - 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 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 uses: actions/upload-artifact@v4
with: 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 if-no-files-found: ignore
path: dist/*.* path: dist/*.*
# 创建 GitHub Release # 创建 GitHub Release

View File

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

View File

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

787
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff