From 1bc2da9c2093d09c5152885d50d454490cf73e90 Mon Sep 17 00:00:00 2001 From: brianling Date: Sun, 19 Jul 2026 14:01:59 +0800 Subject: [PATCH] build: add release script, MSI+NSIS dual bundle, artifacts versioned dir --- README.md | 16 ++++++++++++---- package.json | 3 ++- scripts/copy-artifacts.js | 26 ++++++++++++++++++++++++++ src-tauri/tauri.conf.json | 14 ++++++++++---- 4 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 scripts/copy-artifacts.js diff --git a/README.md b/README.md index 904f1cb..7250253 100644 --- a/README.md +++ b/README.md @@ -34,14 +34,21 @@ Tauri 开发模式会先启动 Vite 开发服务器(端口 5173),然后打 ## 构建 ```bash -# 1. 构建前端 + Rust 二进制 +# 构建前端 + Rust 二进制 + 安装包(MSI + NSIS) npm run tauri build -# 2. 产物位于 src-tauri/target/release/bundle/ -# - Windows: MSI 安装包 (.msi) 或 NSIS 安装程序 (.exe) -# - 便携版: src-tauri/target/release/ai-grading-assistant.exe +# 或者一键构建并汇集产物到版本目录 +npm run release ``` +产物位于 `src-tauri/target/release/v{版本号}/`: + +| 文件 | 说明 | +|------|------| +| `AI阅卷助手_v{版本}_x64.exe` | 便携版(免安装,直接运行) | +| `AI阅卷助手_{版本}_x64_zh-CN.msi` | MSI 安装包 | +| `AI阅卷助手_{版本}_x64-setup.exe` | NSIS 安装程序 | + ## 项目结构 ``` @@ -64,6 +71,7 @@ AIGA-Tauri/ │ ├── icons/ # 应用图标 │ ├── Cargo.toml │ └── tauri.conf.json +├── scripts/ # 构建工具脚本 ├── package.json └── README.md ``` diff --git a/package.json b/package.json index ec7b3b9..b0fbd39 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "dev": "vite", "build": "vue-tsc --noEmit --skipLibCheck && vite build", "preview": "vite preview", - "tauri": "tauri" + "tauri": "tauri", + "release": "npm run tauri build && node scripts/copy-artifacts.js" }, "dependencies": { "@tauri-apps/api": "^2.0.0", diff --git a/scripts/copy-artifacts.js b/scripts/copy-artifacts.js new file mode 100644 index 0000000..0e57e97 --- /dev/null +++ b/scripts/copy-artifacts.js @@ -0,0 +1,26 @@ +import { copyFileSync, mkdirSync, readdirSync, existsSync, readFileSync } from 'fs' +import { resolve, dirname } from 'path' +import { fileURLToPath } from 'url' + +const __dirname = dirname(fileURLToPath(import.meta.url)) +const root = resolve(__dirname, '..') +const pkg = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf-8')) +const ver = pkg.version + +const releaseDir = resolve(root, 'src-tauri/target/release') +const outDir = resolve(releaseDir, `v${ver}`) +if (!existsSync(outDir)) mkdirSync(outDir, { recursive: true }) + +const exe = resolve(releaseDir, 'ai-grading-assistant.exe') +if (existsSync(exe)) copyFileSync(exe, resolve(outDir, `AI阅卷助手_v${ver}_x64.exe`)) + +const bundleDir = resolve(releaseDir, 'bundle') +if (existsSync(bundleDir)) { + for (const sub of readdirSync(bundleDir)) { + for (const file of readdirSync(resolve(bundleDir, sub))) { + copyFileSync(resolve(bundleDir, sub, file), resolve(outDir, file)) + } + } +} + +console.log(`Artifacts copied to ${outDir}`) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 8cbd322..c372054 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/nicegui-org/nicegui-tauri/main/tauri.conf.schema.json", "productName": "AI阅卷助手", "version": "1.0.0", - "identifier": "com.ai-grading-assistant.app", + "identifier": "com.aigrading.assistant", "build": { "frontendDist": "../dist", "devUrl": "http://localhost:5173", @@ -17,11 +17,17 @@ }, "bundle": { "active": true, - "targets": "all", + "targets": ["msi", "nsis"], "icon": [ "icons/32x32.png", "icons/128x128.png", - "icons/128x128@2x.png" - ] + "icons/128x128@2x.png", + "icons/icon.ico" + ], + "windows": { + "wix": { + "language": "zh-CN" + } + } } }