fix(release): publish-update.sh 合并 windows 条目进 latest.json + 新增 win AI 协作说明
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 45s
Verify (Gitea) / gate (build · unit · facts) (push) Successful in 45s
根因:win 应用 endpoints 只配 latest.json,但 publish-update.sh 旧逻辑硬编码只写 darwin 两平台、丢弃 windows 条目 → 每次 mac 发版都抹掉 windows,win 用户「检查更新」找不到自己平台、卡「正在检查…」(v3.25.31 实测踩过,当时手工合并救火)。 修法:写 latest.json 时从 latest-windows.json 读 windows 条目,【仅当 win 清单 version == 本次 mac version(三平台同批)】才合并;版本不一致则拒绝合并并提示「待 win 同批后重跑本脚本」,避免顶层 version 新、win 包旧导致 updater 反复提示同一旧包的死循环。 单测:UPD_VERSION=3.25.31 同批→三平台齐平;=3.25.32 win 没跟上→拒绝合并+警告。bash -n 语法通过。 另:docs/AI-HANDOFF-WINDOWS.md 给 win 端 AI 的认知/边界说明(架构根因、发布链路、职责边界、踩坑记录),配套 WIN_BUILD_SPEC.md(操作清单)。
This commit is contained in:
1 parent
79201e6166
commit
0851c22574
2 files changed
+116
-11
No files matched your search
@@ -0,0 +1,97 @@
|
||||
# 给 Windows 端 AI 的协作说明(Image Workbench 桌面版)
|
||||
|
||||
> 这份文档是给 **Windows 构建端的 AI agent** 读的。读完你应理解:项目架构、为什么 Windows 之前开不了网页、发布链路、你的职责边界、这次踩过的坑。
|
||||
> 详细打包步骤见仓库 `docs/WIN_BUILD_SPEC.md`(gitea/main)。本文是「认知 + 边界」,那份是「操作清单」。
|
||||
|
||||
---
|
||||
|
||||
## 1. 项目是什么
|
||||
|
||||
- Image Workbench:Tauri v2 桌面应用(本地优先的 AI 生图无限画布)。
|
||||
- 仓库:`/Users/qiqi/open/github/image-workbench-desktop`(mac 端),git remote 名为 `gitea`。
|
||||
- 分发:自建 NAS,公网 `https://download.maqiart.eu.org`,根目录 `/vol8/web/iwb-download`。
|
||||
- 版本线:现行 `3.25.x`。**注意**:仓库里最高的 git tag `v3.87.65` 是历史遗留线,semver 更大但**不是**最新——判断最新版看 `package.json` / `CHANGELOG.md` 顶条 / `tauri.conf.json`,永远别按最高 tag。
|
||||
|
||||
---
|
||||
|
||||
## 2. 为什么 Windows 之前「开网页没反应」(核心技术根因)
|
||||
|
||||
应用里有**两条**开网页的路,实现完全不同:
|
||||
|
||||
| 路径 | Rust API | 平台 | 之前 Windows |
|
||||
|---|---|---|---|
|
||||
| 独立浏览器窗口 `open_browser_window` | `WebviewWindowBuilder` + `WebviewUrl::External`,**`async fn`** | 跨平台 | 正常 |
|
||||
| 画布内嵌网页节点 `canvas_webview_*` | `Window::add_child`(子 webview,需 tauri `unstable` feature),**原来是同步 `fn`** | — | **死锁** |
|
||||
|
||||
**根因**(Tauri 2 官方文档 Known issues 原文):
|
||||
> `Window::add_child` / `Window::builder` / `Webview::cookies` 在 **Windows 同步 command 里会 deadlock**(WebView2 限制),必须用 `async` command。
|
||||
|
||||
全工程 `add_child` 只有 1 处调用(`canvas_webview_ensure`),原来是同步 `fn` → 一点画布网页整个 IPC 主线程卡死。
|
||||
|
||||
**修法(v3.25.31 已做)**:把 8 个相关 command 签名 `fn` → `async fn`。这是**跨平台**修法,**不需要任何 `#[cfg(target_os)]` 分支**。JS 端本来就用 Promise 调用,IPC 协议透明,前端零改动。
|
||||
|
||||
**给你的关键认知**:以后看到「Windows 上某个原生能力没反应/卡死,mac 正常」,先怀疑是不是同步 command 里调了 Tauri 的 Windows 限制 API(add_child / cookies 等),而不是 win 环境坏了。
|
||||
|
||||
---
|
||||
|
||||
## 3. 发布链路(mac ↔ win 协作契约)
|
||||
|
||||
```
|
||||
mac 改源码 → mac commit → mac `RELEASE=1 git push gitea main`
|
||||
→ win `git fetch gitea && git reset --hard gitea/main`
|
||||
→ win 构建 setup.exe(npm ci && npm run app:build)
|
||||
→ win 自测矩阵通过
|
||||
→ win 把 setup.exe 放到 NAS `_inbox/`(权限700,公网403)
|
||||
→ 通知 mac:版本 + size + sha256
|
||||
→ mac 签名 + 上传 + 登记 releases.json + 合并 latest.json + push
|
||||
→ win 用户可更新
|
||||
```
|
||||
|
||||
**铁律:源码只在 mac 改,win 只负责构建 + 实测 + 交付。** 不要反向(win 改 → mac 拉),会引入 CRLF 整文件 diff、rustfmt 风格 diff、win-only 死分支。
|
||||
|
||||
---
|
||||
|
||||
## 4. 你的职责边界(AI 必须遵守)
|
||||
|
||||
✅ 你该做:
|
||||
- `git reset --hard gitea\main` 到最新
|
||||
- 核对三处版本一致(package.json / tauri.conf.json / Cargo.toml)+ 确认 lib.rs 里 6 个 `async fn canvas_webview_*` 都在
|
||||
- `npm ci && npm run app:build`
|
||||
- 跑自测矩阵(尤其第 2 项:画布网页节点能打开、不卡死)
|
||||
- 把 `image-workbench_<version>_x64-setup.exe` 放 NAS `_inbox/`
|
||||
- 记录 size + SHA256,通知 mac 端
|
||||
|
||||
❌ 你绝不能做:
|
||||
- **自己签名 / 生成 .sig** —— 更新私钥只在 mac(`~/.config/iwb-updater.key`),win 签出来的 key ID 与项目公钥 `17ae57d0ac9f15f1` 不配对,客户端会拒绝安装(这次 win 放上来的临时 .sig 就被 mac 忽略重签了)
|
||||
- 改 `src-tauri\src\lib.rs` / `Cargo.toml` / `tauri.conf.json` 等任何源码
|
||||
- 跑 `cargo fmt` 或让 IDE 保存即格式化
|
||||
- `git add -A` / `git push gitea main`(push 是 mac 端 `RELEASE=1` 的单独动作)
|
||||
- 把 `target\`、`node_modules\`、`.msi`、`.sig` 提交进 git
|
||||
|
||||
---
|
||||
|
||||
## 5. 这次踩过的坑(让你少走弯路)
|
||||
|
||||
1. **win 自签 .sig 无效**:win 端没有正式私钥,签出来的 sig keyid 对不上,白签。只交 setup.exe,签名交给 mac。
|
||||
2. **`latest.json` 平台解耦 bug**:项目想做 mac/win 独立更新清单(mac→`latest.json`,win→`latest-windows.json`),但**应用的 `tauri.conf.json` endpoints 只配了 `latest.json`**,且 mac 发布脚本 `publish-update.sh` 写清单时**只硬编码 darwin 两平台、丢弃 windows 条目**。结果:win 用户的应用拉 `latest.json` 找不到 `windows-x86_64` → 更新无结果。**临时修**:mac 端把 windows 条目合并回 `latest.json`。**长期修**:改 `publish-update.sh` 合并 windows 条目(mac 端待办)。
|
||||
3. **v3.25.30 旧 win 包 updater 卡「正在检查…」**:那是旧包的 updater 行为/网络,不是发布错。诊断法:浏览器打开 `https://download.maqiart.eu.org/updates/latest.json`,能看到 `windows-x86_64` 即发布侧没问题;旧包用户**直接用网页下载 setup.exe 手动升级**最稳,装上 v3.25.31 后以后就能应用内更新。
|
||||
4. **Windows 画布网页节点无圆角**:`cwv_round` 非 macOS 分支是空 stub,网页节点直角贴卡片。cosmetic,已知缺失,另排 backlog,不影响交付。
|
||||
|
||||
---
|
||||
|
||||
## 6. 验证发布是否到位(win 用户/你都能查)
|
||||
|
||||
```
|
||||
浏览器打开 https://download.maqiart.eu.org/updates/latest.json
|
||||
→ version 应是目标版本,platforms 应含 darwin-aarch64 / darwin-x86_64 / windows-x86_64
|
||||
浏览器打开 https://download.maqiart.eu.org/
|
||||
→ 三平台都应是「下载」按钮,不是「暂未提供」
|
||||
```
|
||||
|
||||
`latest.json` 是 `cf-cache-status: DYNAMIC`(CF 不缓存),改完即时生效,不用等。
|
||||
|
||||
---
|
||||
|
||||
## 7. 一句话给 win AI
|
||||
|
||||
> 你是构建机,不是发布机。拉最新 main → 核对版本和 async 修复 → 构建 → 自测 → 把 setup.exe 丢进 `_inbox` → 报 size/sha256 给 mac。**不签名、不改码、不格式化、不 push。** 网页下载能打开 latest.json 就说明发布没问题,剩下的是 mac 端的事。
|
||||
+19
-11
@@ -72,21 +72,21 @@ echo "== 4/4 生成 latest.json"
|
||||
export SIG_ARM="$(cat "$ARM/macos/image-workbench.app.tar.gz.sig")"
|
||||
export SIG_INT="$(cat "$INT/macos/image-workbench.app.tar.gz.sig")"
|
||||
export UPD_VERSION="$V"
|
||||
# Windows 包单独构建:全局 version 提升后,旧 windows 条目会变成「声明新版本、实际旧安装包」,
|
||||
# 客户端会因 app-version 绑定不一致而拒绝安装。所以每次发布 mac 时明确提示并丢弃过期的非 darwin 条目,
|
||||
# 等 Windows 包跟上再用 publish-windows-update.sh 合并回来。
|
||||
# Windows 包由 win 端构建、mac 端 publish-windows-update.sh 签名发布,写独立的 latest-windows.json。
|
||||
# 但应用 endpoints 只配了 latest.json(mac/win 共用同一份 tauri.conf.json,无法按平台分 endpoint),
|
||||
# 所以 mac 发布【必须】把 windows 条目合并进 latest.json,否则 win 用户「检查更新」找不到自己平台、
|
||||
# 会卡在「正在检查…」(v3.25.31 实测踩过:旧逻辑硬编码只写 darwin,每次 mac 发版都抹掉 windows 条目)。
|
||||
# 合并条件:latest-windows.json 的 version == 本次 mac version(三平台同批)。
|
||||
# 若 win 还没跟上本次版本,【不合并】——避免「顶层 version 新、win 包旧」让 updater 反复提示同一旧包;
|
||||
# 等 win 同批发布后重跑本脚本即自动齐平。
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest.json -o /tmp/iwb-latest-prev.json 2>/dev/null || echo '{}' > /tmp/iwb-latest-prev.json
|
||||
node -e '
|
||||
const fs = require("fs")
|
||||
let prev = {}
|
||||
try { prev = JSON.parse(fs.readFileSync("/tmp/iwb-latest-prev.json", "utf8")) } catch (e) { prev = {} }
|
||||
const stale = (prev.platforms ? Object.keys(prev.platforms) : []).filter(function (k) { return k.indexOf("darwin-") !== 0 && prev.version !== process.env.UPD_VERSION })
|
||||
if (stale.length) console.log("将丢弃过期的非 darwin 平台条目:" + stale.join(","))
|
||||
'
|
||||
curl -s -m 20 https://download.maqiart.eu.org/updates/latest-windows.json -o /tmp/iwb-latest-win.json 2>/dev/null || echo '{}' > /tmp/iwb-latest-win.json
|
||||
|
||||
node -e '
|
||||
const fs = require("fs")
|
||||
const v = process.env.UPD_VERSION
|
||||
let win = {}
|
||||
try { win = JSON.parse(fs.readFileSync("/tmp/iwb-latest-win.json", "utf8")) } catch (e) { win = {} }
|
||||
const j = {
|
||||
version: v,
|
||||
notes: process.env.UPD_NOTES || "",
|
||||
@@ -96,8 +96,16 @@ const j = {
|
||||
"darwin-x86_64": { signature: process.env.SIG_INT, url: "https://download.maqiart.eu.org/updates/darwin-x86_64/image-workbench_" + v + "_x64.app.tar.gz" },
|
||||
},
|
||||
}
|
||||
if (win.platforms && win.platforms["windows-x86_64"]) {
|
||||
if (win.version === v) {
|
||||
j.platforms["windows-x86_64"] = win.platforms["windows-x86_64"]
|
||||
console.log("已合并 windows-x86_64 条目(v" + v + ",三平台齐平)")
|
||||
} else {
|
||||
console.log("⚠ latest-windows.json 仍是 v" + win.version + ",本次 mac 发 v" + v + ":latest.json 暂不含 windows 条目。win 用户停留旧版,待 win 同批发布后【重跑本脚本】即自动齐平(切勿手工塞旧 win 包,会触发 updater 版本错配死循环)。")
|
||||
}
|
||||
}
|
||||
fs.writeFileSync("/tmp/iwb-latest.json", JSON.stringify(j, null, 2))
|
||||
console.log("latest.json -> v" + v)
|
||||
console.log("latest.json -> v" + v + " platforms: " + Object.keys(j.platforms).join(","))
|
||||
'
|
||||
$SCP /tmp/iwb-latest.json "$NAS_HOST:$NAS_DIR/updates/latest.json"
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$NAS_HOST" "chmod -R a+rX $NAS_DIR"
|
||||
|
||||
Reference in new issue
Block a user