From b8b8f747d32d36b69f49d8a23c05ba8eec1587e7 Mon Sep 17 00:00:00 2001 From: awsl1414 <3030994569@qq.com> Date: Wed, 15 Oct 2025 20:16:56 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20build:=20=E5=85=A8=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E9=87=87=E7=94=A8=E5=8E=9F=E7=94=9F=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=20runner=20=E6=9B=BF=E4=BB=A3=E4=BA=A4=E5=8F=89=E7=BC=96?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - feat: Windows ARM64 使用 windows-11-arm 原生 runner - feat: macOS 拆分为独立的 x64 和 ARM64 构建任务 - feat: macOS x64 使用 macos-13 原生 Intel runner - feat: macOS ARM64 使用 macos-15 原生 Apple Silicon runner - feat: Linux ARM64 使用 ubuntu-22.04-arm 原生 runner - fix: 修复 Windows ARM64 交叉编译生成错误 I386 指令集问题 - improve: 移除 QEMU 和交叉编译工具链依赖 - improve: 简化构建配置,提升构建可靠性和性能 - improve: 确保所有平台生成正确架构的可执行文件 --- .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 82 +++++++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88af0c6..b33a7cc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,7 +62,7 @@ jobs: # Windows ARM64 架构 release-arm64: name: Build Electron App for Windows (ARM64) - runs-on: windows-latest + runs-on: windows-11-arm steps: # 检出 Git 仓库 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c707097..6da0dba 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -70,7 +70,7 @@ jobs: # Windows ARM64 架构 build-windows-arm64: name: Build for Windows (ARM64) - runs-on: windows-latest + runs-on: windows-11-arm steps: # 检出 Git 仓库 - name: Check out git repository @@ -124,10 +124,10 @@ jobs: dist/*.exe.blockmap env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} - # macOS - 支持 Intel (x64) 和 Apple Silicon (ARM64) - build-macos: - name: Build for macOS (Universal) - runs-on: macos-latest + # macOS - 分别构建 x64 和 ARM64 + build-macos-x64: + name: Build for macOS (Intel x64) + runs-on: macos-13 steps: # 检出 Git 仓库 - name: Check out git repository @@ -154,17 +154,68 @@ jobs: # 清理旧的构建产物 - 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 + # 构建 Electron App (x64) + - name: Build Electron App for macOS x64 + run: pnpm run build:mac -- --x64 || true shell: bash env: GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} # 上传构建产物 - - name: Upload macOS artifact + - name: Upload macOS x64 artifact uses: actions/upload-artifact@v4 with: - name: SPlayer-macOS + name: SPlayer-macOS-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 }} + + build-macos-arm64: + name: Build for macOS (Apple Silicon ARM64) + runs-on: macos-15 + 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 [ ! -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 macOS ARM64 + run: pnpm run build:mac -- --arm64 || true + shell: bash + env: + GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }} + # 上传构建产物 + - name: Upload macOS ARM64 artifact + uses: actions/upload-artifact@v4 + with: + name: SPlayer-macOS-ARM64 if-no-files-found: ignore path: dist/*.* # 创建 GitHub Release @@ -249,16 +300,11 @@ jobs: # Linux ARM64 架构 build-linux-arm64: name: Build for Linux (ARM64) - runs-on: ubuntu-22.04 + runs-on: ubuntu-22.04-arm 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 @@ -275,9 +321,7 @@ jobs: 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 + sudo apt-get install --no-install-recommends -y libopenjp2-tools # 复制环境变量文件 - name: Copy .env.example run: |