fix(desktop): build

fix(desktop): ci
This commit is contained in:
xxnuo
2026-01-10 00:29:55 +08:00
parent 6864448bcb
commit cc1132a5bd
3 changed files with 22 additions and 20 deletions

View File

@@ -46,6 +46,9 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
env:
GH_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || github.token }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
@@ -135,14 +138,12 @@ jobs:
REPO="${{ github.repository }}"
# Derive version from TAG to be consistent with artifacts
VERSION=${TAG#v}
# Use VERSION derived from tag instead of package.json to ensure consistency with builds
echo "Using version: $VERSION"
if [[ "${{ github.ref_name }}" == *"dev"* ]]; then
WARNING="**This is a development release. DO NOT USE IT!**"$'
'
WARNING=$(printf "**This is a development release. DO NOT USE IT!**\n\n")
else
WARNING=""
fi
@@ -163,11 +164,11 @@ jobs:
| Windows | x64 | [mtranserver-desktop-${VERSION}-win-x64.exe](https://github.com/${REPO}/releases/download/${TAG}/mtranserver-desktop-${VERSION}-win-x64.exe) |
> 桌面端启动后会创建一个托盘菜单,通过菜单可以方便的管理服务。
**macOS**: 拖动安装后,如果打开 MTranServer App 提示 "app is damaged",需要运行以下命令修复:
> If you see "app is damaged" error, run this command in Terminal App:
```bash
sudo xattr -d com.apple.quarantine "/Applications/MTranServer.app"
```
@@ -197,19 +198,19 @@ jobs:
**musl**: 仅适用于 Linux 使用 musl libc 的用户,大多数人不需要这个。
> **musl**: Use only if you are on Linux with musl libc. Most people don't need this.
## Docker
Image: `xxnuo/mtranserver:latest`
可执行文件版本主要面向个人桌面端部署,如果需要更高性能和稳定性,推荐使用 Docker 版本。
> Executable version is mainly for personal desktop deployment. If you need higher performance and stability, it is recommended to use the Docker version.
如果你的 CPU 不支持 AVX 并且使用 legacy 版本也报错,推荐使用 Docker 版本而非可执行文件版本,因为 Docker 版本会自动选择合适的架构运行且速度更快。
> If your CPU does not support AVX and using legacy version also crashes, it is recommended to use the Docker version instead of the executable file version, because the Docker version will automatically select the appropriate architecture to run and is faster.
## Changelog
EOF

View File

@@ -31,7 +31,7 @@
"build:node": "bun scripts/build.ts --node",
"build:dev": "bun scripts/build.ts --dev",
"build:lib": "bun scripts/build.ts --lib",
"build:electron": "bun run build:node && electron-builder"
"build:electron": "bun run scripts/electron-build.ts"
},
"keywords": [
"translation",
@@ -68,6 +68,7 @@
"node": ">=18.0.0"
},
"build": {
"publish": null,
"appId": "com.github.xxnuo.mtranserver",
"productName": "MTranServer",
"executableName": "mtranserver",
@@ -76,17 +77,17 @@
"buildDependenciesFromSource": false,
"copyright": "Copyright © 2025",
"extraMetadata": {
"main": "dist/main-bundled.js"
"main": "dist/desktop-bundled.js"
},
"asar": true,
"asar": false,
"artifactName": "mtranserver-desktop-${version}-${os}-${arch}.${ext}",
"files": [
"desktop/**/*",
"scripts/electron-main.js",
"dist/**/*",
"!dist/mtranserver*",
"!dist/*.exe",
"images/**/*",
"!dist/main.js",
"!dist/desktop.js",
"images/icons/**/*",
"package.json"
],
"directories": {

View File

@@ -24,7 +24,7 @@ async function main() {
console.log('Building for Node with Bun...')
await run(bunBin, ['run', 'build:node'])
const outfile = path.join(root, 'dist', 'main-bundled.js')
const outfile = path.join(root, 'dist', 'desktop-bundled.js')
console.log(`Building Electron main process to ${outfile}...`)
await run(bunBin, [
@@ -33,12 +33,12 @@ async function main() {
'--target', 'node',
'--external', 'electron',
'--format', 'esm',
'--sourcemap'
'--minify', '--bundle'
])
// Verify and fix location if Bun misbehaved
if (!fs.existsSync(outfile)) {
const wrongLoc = path.join(root, 'scripts', 'main-bundled.js')
const wrongLoc = path.join(root, 'scripts', 'desktop-bundled.js')
if (fs.existsSync(wrongLoc)) {
console.log(`Moving build output from ${wrongLoc} to ${outfile}...`)
fs.renameSync(wrongLoc, outfile)