mirror of
https://gitee.com/dlmu-cone/Arborflow
synced 2026-10-23 17:52:20 +08:00
build: package platform releases
This commit is contained in:
55
.github/workflows/build-release.yml
vendored
Normal file
55
.github/workflows/build-release.yml
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
name: Build release packages
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
package:
|
||||
name: Package ${{ matrix.platform }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- platform: windows
|
||||
os: windows-latest
|
||||
command: dist:win
|
||||
- platform: linux
|
||||
os: ubuntu-22.04
|
||||
command: dist:linux
|
||||
- platform: macos
|
||||
os: macos-14
|
||||
command: dist:mac
|
||||
|
||||
env:
|
||||
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
||||
|
||||
steps:
|
||||
- name: Check out source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Build packages
|
||||
run: npm run ${{ matrix.command }}
|
||||
|
||||
- name: Upload packages
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ArborFlow-${{ matrix.platform }}
|
||||
path: release/${{ matrix.platform }}/
|
||||
if-no-files-found: error
|
||||
compression-level: 0
|
||||
@@ -218,7 +218,9 @@ npm run dist:linux
|
||||
npm run dist:mac
|
||||
```
|
||||
|
||||
输出目录为 `release/`。建议在目标操作系统上执行对应打包命令,特别是 macOS 签名、公证以及不同 CPU 架构的构建。
|
||||
输出按平台分别保存到 `release/windows/`、`release/linux/` 和 `release/macos/`。建议在目标操作系统上执行对应打包命令,特别是 macOS 签名、公证以及不同 CPU 架构的构建。
|
||||
|
||||
仓库内的 `.github/workflows/build-release.yml` 会在 Windows、Ubuntu 和 macOS 原生运行器上并行打包。可在 GitHub Actions 中手动运行,也会在推送 `v*` 标签时自动执行并上传三个独立平台产物。
|
||||
|
||||
可用的默认目标:
|
||||
|
||||
@@ -247,6 +249,9 @@ npm run icon:render
|
||||
| `npm run dist:win` | 构建 Windows 包 |
|
||||
| `npm run dist:linux` | 构建 Linux 包 |
|
||||
| `npm run dist:mac` | 构建 macOS 包 |
|
||||
| `npm run pack:win` | 不重复构建前端,直接生成 Windows 包 |
|
||||
| `npm run pack:linux` | 不重复构建前端,直接生成 Linux 包 |
|
||||
| `npm run pack:mac` | 不重复构建前端,直接生成 macOS 包 |
|
||||
|
||||
## 项目结构
|
||||
|
||||
|
||||
11
package.json
11
package.json
@@ -10,10 +10,13 @@
|
||||
"dev": "concurrently -k \"vite --host 127.0.0.1\" \"wait-on http://127.0.0.1:5173 && electron .\"",
|
||||
"build": "tsc -b && vite build",
|
||||
"preview": "vite preview --host 127.0.0.1",
|
||||
"dist": "npm run build && electron-builder",
|
||||
"dist:linux": "npm run build && electron-builder --linux",
|
||||
"dist:mac": "npm run build && electron-builder --mac",
|
||||
"dist:win": "npm run build && electron-builder --win",
|
||||
"dist": "node scripts/dist-current.cjs",
|
||||
"dist:linux": "npm run build && npm run pack:linux",
|
||||
"dist:mac": "npm run build && npm run pack:mac",
|
||||
"dist:win": "npm run build && npm run pack:win",
|
||||
"pack:linux": "electron-builder --linux --config.directories.output=release/linux",
|
||||
"pack:mac": "electron-builder --mac --config.directories.output=release/macos",
|
||||
"pack:win": "electron-builder --win --config.directories.output=release/windows",
|
||||
"mock:monitor": "node scripts/mock-monitor.cjs",
|
||||
"icon:render": "electron scripts/render-icon.cjs"
|
||||
},
|
||||
|
||||
25
scripts/dist-current.cjs
Normal file
25
scripts/dist-current.cjs
Normal file
@@ -0,0 +1,25 @@
|
||||
const { spawnSync } = require('node:child_process');
|
||||
|
||||
const platformTarget = {
|
||||
darwin: 'mac',
|
||||
linux: 'linux',
|
||||
win32: 'win',
|
||||
};
|
||||
|
||||
const target = platformTarget[process.platform];
|
||||
if (!target) {
|
||||
console.error(`Unsupported packaging platform: ${process.platform}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const npmCommand = process.platform === 'win32' ? 'npm.cmd' : 'npm';
|
||||
const result = spawnSync(npmCommand, ['run', `dist:${target}`], {
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
console.error(result.error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(result.status ?? 1);
|
||||
Reference in New Issue
Block a user