70 lines
3.7 KiB
Markdown
70 lines
3.7 KiB
Markdown
> ⚠️ **命令示例已过时**:现行发布命令为 `bash scripts/publish-update.sh`(不带版本参数,版本取自 `package.json`);Windows 用 `publish-windows-update.sh` 并在 mac 侧重跑 `publish-update.sh` 合并 `latest.json`。
|
||
|
||
# 在线更新(Tauri Updater)
|
||
|
||
> 目标:用户装过一次之后,以后新版本在应用内点「检查更新」即可升级,不用再手动下载 dmg。
|
||
|
||
## 一、已经配好的东西
|
||
|
||
| 组件 | 位置 | 说明 |
|
||
|---|---|---|
|
||
| 更新插件 | `src-tauri/Cargo.toml` → `tauri-plugin-updater` | Rust 侧用 `UpdaterExt` |
|
||
| 更新源(macOS) | `src-tauri/tauri.conf.json` → `plugins.updater.endpoints` | `https://download.maqiart.eu.org/updates/latest.json` |
|
||
| 更新源(Windows) | `src-tauri/tauri.windows.conf.json` → `plugins.updater.endpoints` | `https://download.maqiart.eu.org/updates/latest-windows.json`(自 `856e34a`;旧装机仍可能读 latest.json) |
|
||
| 签名公钥 | 同上 `plugins.updater.pubkey` | 私钥在 `~/.config/iwb-updater.key`(**务必备份**) |
|
||
| 产物开关 | `bundle.createUpdaterArtifacts: true` | 构建 app 时额外产出 `.app.tar.gz` + `.sig` |
|
||
| Rust 命令 | `check_update` / `install_update` | 前端通过 `__TAURI__.core.invoke` 调用 |
|
||
| 前端入口 | 设置 → 通用 → 版本与更新 | 「检查更新」→「立即更新」→ 自动重启 |
|
||
|
||
## 二、发新版本(一条命令)
|
||
|
||
```bash
|
||
bash scripts/publish-update.sh # 版本取自 package.json;双架构构建 + 签名 + 上传 + 生成 latest.json
|
||
```
|
||
|
||
脚本会做四件事:
|
||
|
||
1. `npx tauri build --bundles app,dmg`(arm64,带签名)
|
||
2. `npx tauri build --target x86_64-apple-darwin --bundles app,dmg`(Intel,带签名)
|
||
3. 上传 `*.app.tar.gz` / `.sig` / `.dmg` 到 NAS `updates/darwin-{aarch64,x86_64}/`
|
||
4. 生成并上传 `updates/latest.json`(两个平台各自带 signature + url)
|
||
|
||
## 三、latest.json 格式(脚本自动生成)
|
||
|
||
```json
|
||
{
|
||
"version": "X.Y.Z",
|
||
"notes": "更新说明",
|
||
"pub_date": "2026-11-17T09:43:08.117Z",
|
||
"platforms": {
|
||
"darwin-aarch64": { "signature": "<.sig 内容>", "url": "https://.../image-workbench_X.Y.Z_aarch64.app.tar.gz" },
|
||
"darwin-x86_64": { "signature": "<.sig 内容>", "url": "https://.../image-workbench_X.Y.Z_x64.app.tar.gz" }
|
||
}
|
||
}
|
||
```
|
||
|
||
⚠️ **两个平台都要有**:缺哪个平台,那个平台的用户就永远「已是最新」。
|
||
|
||
## 四、用户侧流程
|
||
|
||
1. 装过任一 3.26.54+ 版本(更早版本需先手动装一次带更新器的包)
|
||
2. 设置 → 通用 → 版本与更新 → **检查更新**
|
||
3. 有新版本 → 显示版本号与说明 → 点「立即更新」
|
||
4. 自动下载、校验签名、替换、重启(数据目录不受影响)
|
||
|
||
## 五、注意
|
||
|
||
- **私钥丢了就不能再发更新**(签名对不上,所有旧客户端会拒绝安装)。备份 `~/.config/iwb-updater.key`
|
||
- 公钥写在 `tauri.conf.json` 里进了仓库;私钥**绝不能**进仓库
|
||
- macOS 未做 notarization:更新替换后仍是未签名 app,首次打开可能仍要右键→打开
|
||
- Windows 将来出包时,在 latest.json 里加 `windows-x86_64`,并在 `bundle.targets` 里用 `nsis`(msi 不支持 updater)
|
||
- Cloudflare 会缓存 404:新文件名第一次访问可能短暂 404,换文件名(内容变即哈希变)即可绕过
|
||
|
||
## 六、首次接入清单(已完成 2026-11-17)
|
||
|
||
- [x] 生成密钥对(`tauri signer generate`),公钥进 config,私钥留本机
|
||
- [x] 加 `tauri-plugin-updater`,注册 `check_update` / `install_update`
|
||
- [x] `createUpdaterArtifacts: true`
|
||
- [x] 构建 3.25.2(arm + Intel)并发布 latest.json
|
||
- [ ] 用户实测:装 3.25.2 后,3.25.3 发布时能一键更新(待验证)
|