build: macOS 打包脚本确保生成 DMG 安装包

根因:build_macos_pyinstaller.sh Step 3 显式指定 --bundles app,覆盖了
tauri.conf.json 里的 dmg target,只生成 .app 然后手动打 ZIP,完全没生成 DMG。

修复:
1. --bundles app → --bundles app,dmg(同时构建 .app 和 .dmg)
2. Step 4 增加 DMG 产物收集:从 bundle/dmg/*.dmg 复制到 dist/,
   命名 YunOPC-Hub-{VERSION}-macOS.dmg,输出大小和路径
3. 构建完成摘要增加 DMG 路径
4. package.json 增加快捷脚本:tauri:dev / tauri:build /
   tauri:build:mac / tauri:build:mac:debug
5. tauri.conf.json bundle.macOS.dmg 增加专业配置:
   windowSize [640,440] + applicationFolder=true(DMG 内显示
   /Applications 快捷方式,支持拖拽安装)

macOS DMG 打包依赖系统自带 hdiutil,无需额外安装。
This commit is contained in:
Pine
2026-09-07 23:29:53 +08:00
parent c8a704d65d
commit f135a07ebe
3 changed files with 34 additions and 5 deletions
+8 -3
View File
@@ -17,7 +17,11 @@
"preview:test": "vite preview --mode test",
"test": "vitest",
"test:run": "node --max-old-space-size=4096 ./node_modules/vitest/vitest.mjs run",
"test:coverage": "node --max-old-space-size=4096 ./node_modules/vitest/vitest.mjs run --coverage"
"test:coverage": "node --max-old-space-size=4096 ./node_modules/vitest/vitest.mjs run --coverage",
"tauri:dev": "tauri dev",
"tauri:build": "tauri build",
"tauri:build:mac": "tauri build --bundles app,dmg",
"tauri:build:mac:debug": "tauri build --debug --bundles app,dmg"
},
"dependencies": {
"3d-force-graph": "1.80.0",
@@ -97,6 +101,7 @@
"repository": "https://github.com/agentscope-ai/agentscope-runtime.git",
"packageManager": "yarn@4.18.0",
"resolutions": {
"@types/react": "18.3.31"
"@types/react": "18.3.31",
"@agentscope-ai/design@npm:1.0.32": "patch:@agentscope-ai/design@npm%3A1.0.32#./.yarn/patches/@agentscope-ai-design-1.0.32.patch"
}
}
}
+8 -1
View File
@@ -65,7 +65,14 @@
}
},
"macOS": {
"minimumSystemVersion": "14.0"
"minimumSystemVersion": "14.0",
"dmg": {
"windowSize": [
640,
440
],
"applicationFolder": true
}
},
"createUpdaterArtifacts": true
},
+18 -1
View File
@@ -128,7 +128,7 @@ cd console
echo "Building for macOS..."
npm exec -- tauri build \
--config src-tauri/tauri.version.conf.json \
--bundles app
--bundles app,dmg
cd ..
echo "Tauri app built"
echo ""
@@ -190,6 +190,22 @@ else
fi
echo ""
# Collect DMG disk image (Tauri dmg bundle target)
DMG_GLOB="${BUNDLE_DIR}/dmg"/*.dmg
DMG_FILES=(${DMG_GLOB})
if [ ${#DMG_FILES[@]} -gt 0 ] && [ -f "${DMG_FILES[0]}" ]; then
DMG_SRC="${DMG_FILES[0]}"
DMG_NAME="YunOPC-Hub-${VERSION}-macOS.dmg"
DMG_DEST="${DIST_ROOT}/${DMG_NAME}"
cp -f "${DMG_SRC}" "${DMG_DEST}"
DMG_SIZE=$(du -sh "${DMG_DEST}" | cut -f1)
echo "Created ${DMG_DEST} (${DMG_SIZE})"
else
echo "WARNING: No DMG file found at ${BUNDLE_DIR}/dmg/*.dmg"
echo " Tauri dmg bundle may have been skipped. Check that hdiutil is available."
fi
echo ""
UPDATER_NAME="${DIST_ROOT}/YunOPC-Hub-${VERSION}-macOS.app.tar.gz"
case "$(uname -m)" in
arm64 | aarch64) UPDATER_TARGET="darwin-aarch64" ;;
@@ -215,6 +231,7 @@ echo "========================================="
echo "App: ${APP_PATH}"
echo "Distribution: ${DIST_DIR}"
echo "Archive: ${ZIP_NAME}"
echo "DMG: ${DMG_DEST:-not generated}"
echo "Updater: ${UPDATER_NAME}"
echo ""
echo "Test: open \"${STAGED_APP_PATH}\""