Fix Windows app release packaging

This commit is contained in:
musi
2026-07-28 20:32:06 +08:00
parent 96fb9d5614
commit 497c18e1b6
6 changed files with 54 additions and 4 deletions
+1 -3
View File
@@ -205,9 +205,7 @@ jobs:
- name: Build and publish Windows artifacts
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npm run build:assets
npx electron-builder --win --publish always
run: npm run build:app:win:release -- --publish always
linux:
name: Linux
+11
View File
@@ -222,6 +222,17 @@ docker compose up -d --build
Docker exposes the management UI and gateway routes through `http://127.0.0.1:3458` by default. Read the [Docker deployment guide](https://ccrdesk.top/en/guides/docker/) before exposing CCR remotely.
## Build desktop apps
Install Node.js 22+, then run `npm ci`.
| Target | Command | Output |
| --- | --- | --- |
| macOS local DMG/ZIP | `npm run build:app:mac` | `release-local/` |
| Windows local NSIS installer | `npm run build:app:win` | `release-local/` |
Windows app packaging must run on Windows x64 because `better-sqlite3` ships a native Electron module. The release workflow builds macOS on macOS runners and Windows on `windows-latest` when a `v*` tag is pushed.
## How it works
```text
+11
View File
@@ -222,6 +222,17 @@ docker compose up -d --build
Docker 默认通过 `http://127.0.0.1:3458` 提供管理界面与网关路由。远程暴露 CCR 前,请先阅读 [Docker 部署指南](https://ccrdesk.top/guides/docker/)。
## 构建桌面应用
先安装 Node.js 22+,然后执行 `npm ci`
| 目标 | 命令 | 产物目录 |
| --- | --- | --- |
| macOS 本地 DMG/ZIP | `npm run build:app:mac` | `release-local/` |
| Windows 本地 NSIS 安装包 | `npm run build:app:win` | `release-local/` |
Windows App 打包必须在 Windows x64 上运行,因为 `better-sqlite3` 包含 Electron 原生模块,不能从 macOS 或 Linux 交叉编译。推送 `v*` tag 时,release workflow 会分别在 macOS runner 和 `windows-latest` 上构建 macOS 与 Windows 产物。
## 工作方式
```text
+27
View File
@@ -0,0 +1,27 @@
const errors = [];
if (process.platform !== "win32") {
errors.push(
[
"Windows app builds must run on Windows.",
"This package includes better-sqlite3, and node-gyp cannot cross-compile its native Electron binary from macOS or Linux.",
"Use a Windows x64 machine or the GitHub Actions Windows release job."
].join(" ")
);
}
if (process.arch !== "x64") {
errors.push(
`Windows packaging is configured for x64 NSIS artifacts, but this Node.js process is ${process.arch}. Run the build with x64 Node.js on Windows.`
);
}
if (errors.length > 0) {
console.error("Windows packaging preflight failed:");
for (const error of errors) {
console.error(`- ${error}`);
}
process.exit(1);
}
console.log("Windows packaging preflight passed.");
+3 -1
View File
@@ -40,7 +40,9 @@
"build:app:mac": "npm run build:app:mac:local",
"build:app:mac:local": "npm run build:assets && electron-builder --config build/electron-builder.local.cjs --mac --publish never",
"build:app:mac:release": "node build/macos-release-preflight.mjs && npm run models:update && npm run build:assets && electron-builder --mac --publish never",
"build:app:win": "npm run build:assets && electron-builder --win",
"build:app:win": "npm run build:app:win:local",
"build:app:win:local": "node build/windows-package-preflight.mjs && npm run build:assets && electron-builder --config build/electron-builder.local.cjs --win --publish never",
"build:app:win:release": "node build/windows-package-preflight.mjs && npm run build:assets && electron-builder --win",
"models:update": "node scripts/generate-models-json.mjs",
"prepack": "npm run models:update && npm run build:assets",
"prepublishOnly": "npm run typecheck",
+1
View File
@@ -3,6 +3,7 @@
"version": "3.0.16",
"private": true,
"description": "Claude Code Router Electron desktop shell.",
"author": "musistudio",
"main": "dist/main/main.js",
"scripts": {
"test": "node ../../build/test.mjs electron && node ../../build/run-tests.mjs electron",