Skip to content

feat(updater): 增加应用自动更新入口#84

Closed
H-Chris233 wants to merge 1 commit into
Open-Less:mainfrom
H-Chris233:main
Closed

feat(updater): 增加应用自动更新入口#84
H-Chris233 wants to merge 1 commit into
Open-Less:mainfrom
H-Chris233:main

Conversation

@H-Chris233
Copy link
Copy Markdown
Collaborator

摘要

Fixes #33

本 PR 增加应用自动更新能力,让用户可以在应用内检查、下载并安装新版本,无需手动前往 Release 页面下载安装包。

当前实现采用“用户手动检查更新”的交互方式:在“关于”区域展示当前版本和“检查”按钮。用户点击后,如果没有新版本则提示当前已是最新版本;如果发现新版本,则弹窗询问是否现在更新。确认更新后显示下载进度,下载并安装完成后再询问是否现在重启应用。

同时保留 release 侧签名更新包和 manifest 生成逻辑,因为 Tauri updater 依赖签名包与 manifest 才能完成更新校验和安装。

修复 / 新增 / 改进

  • 在“关于”区域的当前版本旁新增“检查”按钮。

  • 点击“检查”后执行更新检查:

    • 无更新时显示“当前已是最新版本”
    • 有更新时弹窗询问是否现在更新
  • 点击“现在更新”后:

    • 弹窗显示下载进度条
    • 执行更新包下载与安装
    • 安装完成后弹窗询问是否现在自动重启
  • 点击“现在重启”后:

    • 调用 app restart
    • 重启应用后新版本生效
  • 点击“稍后手动重启”后:

    • 关闭弹窗
    • 用户之后手动重启应用后更新生效
  • 保留 release 侧更新包签名与 manifest 生成逻辑:

    • 保证 Tauri updater 可以校验更新包
    • 保证客户端可以读取更新 manifest
    • 保证发布流程仍能产出 updater 所需文件

兼容

  • 不包含:

    • 不实现后台静默自动更新。
    • 不强制用户立即安装更新。
    • 不强制用户立即重启应用。
    • 不移除现有 release 构建逻辑。
    • 不改变用户手动下载安装包的备用路径。
    • 不引入非 Tauri updater 的额外更新框架。
  • 对现有用户 / 本地环境 / 构建流程的影响:

    • 用户可以从应用内手动检查并安装更新。
    • 有更新时,用户仍可以选择是否立即更新。
    • 更新安装完成后,用户可以选择立即重启或稍后手动重启。
    • 发布侧仍需要生成 Tauri updater 依赖的签名更新包和 manifest。
    • 本地普通开发流程无额外要求。

测试计划

  • 命令:npm run build

  • 结果:通过

  • 证据路径:本地构建输出

  • 命令:cargo check

  • 结果:通过,仅有既有 warnings

  • 证据路径:本地检查输出

  • 命令:npm run tauri -- build --debug --no-bundle --ci

  • 结果:通过

  • 证据路径:本地构建输出,已验证 Tauri 配置和权限可以实际构建

  • 命令:git diff --check

  • 结果:通过

  • 证据路径:本地命令输出

备注

本 PR 实现的是用户主动触发的应用内更新流程,不是后台静默更新。安装完成后仍保留重启确认,避免在用户未确认的情况下直接重启应用。

@appergb

Issue Open-Less#33 requires users to control updates instead of being silently
moved to a new version. The app now exposes a manual check beside the
About version, prompts before installing, shows download/install state,
and lets users choose whether to restart immediately.

Release builds also publish the signed updater bundles and per-platform
manifests needed by Tauri's updater while keeping unsigned manual CI runs
usable for build validation.

Constraint: Tauri updater requires signed artifacts and a public-key manifest
Constraint: User requested no silent automatic updates
Rejected: Startup background update check | violates the requested confirmation flow
Rejected: Always requiring updater signing for workflow_dispatch | would break test builds without release secrets
Confidence: high
Scope-risk: moderate
Directive: Do not reintroduce startup update checks without explicit product approval
Tested: npm run build
Tested: cargo check
Tested: npm run tauri -- build --debug --no-bundle --ci
Tested: git diff --check; node --check write-updater-manifest.mjs; bash -n build-mac.sh
Not-tested: Live tagged GitHub Actions release run with updater signing secret
Related: Open-Less#33
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @H-Chris233, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

appergb pushed a commit that referenced this pull request Apr 30, 2026
H-Chris233: closes #33。

实现 Tauri 内置 updater 集成:
- Cargo: tauri-plugin-updater v2
- tauri.conf.json: 加 updater 配置(pubkey + endpoint 指向 GitHub Releases latest)
- capabilities/default.json: 授予 updater:default 能力
- lib.rs: 注册 updater 插件 + restart_app 命令
- src/pages/Settings.tsx + i18n: 关于区域加'检查'按钮、检查/下载/安装/重启对话框流
- 新脚本 scripts/write-updater-manifest.mjs: release 侧从 build artifact 拉签名生成 manifest
- workflow: TAURI_SIGNING_PRIVATE_KEY env + 各平台 build 时 createUpdaterArtifacts true

注意:下次 v*-tauri tag 必须配 TAURI_SIGNING_PRIVATE_KEY secret,否则 CI 硬失败。
@appergb
Copy link
Copy Markdown
Collaborator

appergb commented Apr 30, 2026

本地 squash-merge 到 main 后 push(绕过 OAuth workflow scope 限制)。see commit a9c81e6

@appergb appergb closed this Apr 30, 2026
appergb pushed a commit that referenced this pull request Apr 30, 2026
…attr

修复 Codex audit 对 main HEAD a9c81e6 的 2 条 HIGH + 把 macOS auto-update 的
"重启后 Gatekeeper 拦截"问题封死。

## HIGH #2: 版本号不一致
PR #84 没顺手 bump 版本,main 仍自报 1.2.2,下次直接打 v1.2.3-tauri 会让 updater
manifest 自报 1.2.2,已安装的 1.2.2 客户端永远拿不到 "有新版本"。

修:package.json + tauri.conf.json + Cargo.toml 全部改 1.2.3。

## HIGH #1: updater pubkey 所有权
PR #84 使用的 pubkey 是外部贡献者本地生成的,appergb 不掌握对应 private key。
任何持有那把私钥的人都能签发更新 -> 客户端 OTA 装上恶意版本。

修:
- 用 npx @tauri-apps/cli signer generate --ci 生成 appergb 自己的 keypair
- 新 pubkey: F0FCDE68E08E6D4E (写入 tauri.conf.json plugins.updater.pubkey)
- 私钥已通过 gh secret set TAURI_SIGNING_PRIVATE_KEY 配到 GitHub repo secret
- 私钥本地副本只在 /tmp,不进 git,commit 后会清除

## macOS auto-update 后 strip xattr
restart_app 在 app.restart() 前对 .app bundle 跑 /usr/bin/xattr -cr。这是
Tauri auto-updater + 未公证应用的组合下唯一让"自动更新对用户零摩擦"的解法 —
否则 Gatekeeper 在重启时会拦说"OpenLess 已损坏",用户必须开终端 xattr 才能
继续用,违反 auto-update 的本意。

未来发版逻辑必须保留这一步。release-tauri.yml 上一次 PR (#83) 已经在 CI 侧
strip 过一次,本次在 client 侧重启时再 strip 一次,双保险覆盖
"下载 -> 解压 -> 安装 -> 重启"全链路。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

自动更新

2 participants