Skip to content

feat(updater): Beta 渠道接通 auto-update(Builder.endpoints runtime 切换) - #465

Merged
appergb merged 3 commits into
betafrom
feat/beta-auto-update
May 17, 2026
Merged

feat(updater): Beta 渠道接通 auto-update(Builder.endpoints runtime 切换)#465
appergb merged 3 commits into
betafrom
feat/beta-auto-update

Conversation

@appergb

@appergbappergb commented May 17, 2026

Copy link
Copy Markdown
Collaborator

User description

Summary

CLAUDE.md 之前的论断「tauri-plugin-updater 2.10 Builder 不暴露 endpoints()」在 2.10.1 已不成立 —— Builder 现在有 .endpoints(Vec<Url>) -> Result<Self>build()self.endpoints.unwrap_or_else(|| self.config.endpoints.clone()) 走 runtime 覆盖。

本 PR 用这个新 API 接通 Beta 渠道的自动更新 —— 不 fork plugin、不写自定义下载/签名校验,复用 plugin 全部 plumbing。

What changed

Rust

  • commands.rs::app_check_update_with_channel
    • Stable → webview.updater_builder().build()?.check()(默认 endpoints 从 tauri.conf)
    • Beta → fetch_latest_beta_release() 拿最新 prerelease tag → 拼镜像 + 直连两份 -beta manifest URL → builder.endpoints(urls)?.build()?.check()
  • AppUpdateMetadata 字段形状对齐 plugin 的 UpdateMetadatarid + currentVersion + version + body + rawJson),前端 new Update(metadata) 即可复用 plugin 的 download / install / close
  • lib.rs 注册新 command。

前端

  • AutoUpdate.tsx::checkForUpdatesimport('@tauri-apps/plugin-updater').check 改为 invoke('app_check_update_with_channel');其余 download / install / close 全走 plugin 原生 JS API。
  • SettingsModal::BetaChannelControl 删掉「打开 GitHub 下载」按钮 —— auto-update 接管了,手动下载路径冗余;保留「最新 Beta 版本号 + 刷新」做信息透明。
  • i18n 5 个 locale 改 betaChannelDesc 文案:「需要手动下载安装」→「自动接收最新 Beta 版本」。

物理隔离仍生效

Beta tag 的 manifest 文件名带 -beta 后缀(latest-{tgt}-{arch}-beta.json),跟 Stable 的 latest-{tgt}-{arch}.json 在 GitHub Release assets 里是分开的两份。即使代码逻辑错把 Beta URL 传给 Stable 用户也是 HTTP 404,不会拿到错档。

Test plan

  • cargo test --lib -- --test-threads=1: 270 / 0 / 0
  • npx tsc --noEmit exit 0
  • npm run build clean
  • 装包后手动验:Stable 用户走「检查更新」→ 拿 Stable manifest;切到 Beta toggle → 「检查更新」拿最新 Beta tag 的 manifest;切回 Stable → 回到 Stable manifest。
  • 极端:Beta 渠道但还没发过任何 Beta release → check 返回明确错误「尚未发布过 Beta 版本」而非死循环。

PR Type

Enhancement


Description

  • Add channel-aware update checking

    • Stable uses configured endpoints
    • Beta resolves prerelease manifests
  • Reuse plugin update workflow

    • new Update(metadata) for install
    • No custom download logic
  • Update Beta channel UI

    • Show latest Beta status
    • Add in-app update button
  • Refresh copy and versioning

    • Update i18n descriptions
    • Bump app and release versions

Diagram Walkthrough

flowchart LR
A["Beta channel setting"] -- "chooses" --> B["Rust update check"]
B -- "Stable" --> C["tauri.conf endpoints"]
B -- "Beta" --> D["latest prerelease manifest URLs"]
C -- "check()" --> E["plugin updater"]
D -- "endpoints().check()" --> E["plugin updater"]
E -- "returns metadata" --> F["Frontend Update dialog"]
F -- "download/install/close" --> G["native plugin workflow"]
Loading

File Walkthrough

Relevant files
Enhancement
4 files
commands.rs
Add channel-aware updater command
+102/-5
lib.rs
Register the new update command
+1/-0
AutoUpdate.tsx
Switch checks to backend metadata
+39/-5
SettingsModal.tsx
Add Beta update action to settings
+78/-7
Documentation
5 files
en.ts
Update English Beta channel copy
+5/-1
ja.ts
Update Japanese Beta channel copy
+5/-1
ko.ts
Update Korean Beta channel copy
+5/-1
zh-CN.ts
Update Simplified Chinese Beta copy
+5/-1
zh-TW.ts
Update Traditional Chinese Beta copy
+5/-1
Configuration changes
3 files
package.json
Bump application version number
+1/-1
Cargo.toml
Bump Rust package version number
+1/-1
tauri.conf.json
Bump Tauri app version number
+1/-1

CLAUDE.md 之前的论断「tauri-plugin-updater 2.10 Builder 不暴露 endpoints()」在
2.10.1 已不成立 —— Builder 现在有 .endpoints(Vec<Url>) -> Result<Self>,build()
里 self.endpoints.unwrap_or_else(|| self.config.endpoints.clone()) 走 runtime 覆盖。
实现 channel-aware 自动更新(不 fork plugin、不写自定义下载/签名校验):
Rust(~100 行新增)
- commands.rs::app_check_update_with_channel:
Stable → webview.updater_builder().build()?.check()(默认 endpoints 从 tauri.conf)
Beta → fetch_latest_beta_release() → 拼镜像 + 直连两份 -beta manifest URL
→ builder.endpoints(urls)?.build()?.check()
- AppUpdateMetadata 字段形状对齐 plugin 的 UpdateMetadata(rid + currentVersion
+ version + body + rawJson),前端 new Update(metadata) 即可复用 plugin 的
download / install / close。
- lib.rs 注册新 command。
前端(~30 行改动)
- AutoUpdate.tsx::checkForUpdates 从 import('@tauri-apps/plugin-updater').check
改为 invoke('app_check_update_with_channel');其余 download / install / close
全走 plugin 原生 JS API(new Update(metadata) 后链式调用)。
- SettingsModal::BetaChannelControl 删掉「打开 GitHub 下载」按钮 ——
auto-update 接管了,手动下载路径冗余;保留「最新 Beta 版本号 + 刷新」做信息透明。
- i18n 5 个 locale 改 betaChannelDesc 文案,把「需要手动下载安装」改成
「自动接收最新 Beta 版本」。betaChannelDownloadBtn 等 i18n key 暂留(无用但无害)。
物理隔离仍生效:Beta tag 的 manifest 文件名带 -beta 后缀,跟 Stable 的
latest-{tgt}-{arch}.json 在 GitHub Release assets 里是分开两份;即使代码逻辑
错把 Beta URL 给 Stable 用户也是 HTTP 404,不会拿到错档。
验证:cargo test --lib serial 270 / 0 / 0;tsc clean;vite build clean。
@github-actions

github-actionsBot commented May 17, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit 7cdb623)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Broken Mirror URL

The beta mirror endpoint is built as ...-beta-mirror.json, while the direct endpoint uses ...-beta.json. Unless the release workflow also uploads a separate -beta-mirror.json asset, the first endpoint will always 404, so beta checks lose the intended mirror fallback behavior and add avoidable latency for users behind GitHub access issues.

let mirror = format!("https://fastgit.cc/https://github.com/appergb/openless/releases/download/{tag}/latest-{{{{target}}}}-{{{{arch}}}}-beta-mirror.json");let direct = format!("https://github.com/appergb/openless/releases/download/{tag}/latest-{{{{target}}}}-{{{{arch}}}}-beta.json");

之前 BetaChannelControl 在 toggle 打开后,只机械显示「最新 Beta: vX-beta-tauri」,
不管本机版本是不是已经等于那个 tag。用户报告:「显示有最新 Beta,但应该比对版本号」。
修复:
- parseVersionFromBetaTag("v1.3.4-1-beta-tauri") → "1.3.4-1"
- semverGreater(remote, local) 做 SemVer 风格比对(支持 X.Y.Z 和 X.Y.Z-N,覆盖
本仓库实际版本格式;prerelease 按 SemVer 规则 lower than no-prerelease)
- 本机 >= 最新 → 「最新 Beta: vX」 + 蓝色「已是最新」chip
- 本机 < 最新 → 「最新 Beta: vX」 + 「立即更新」按钮(蓝色高亮)
- 「立即更新」点击 → useAutoUpdate.checkForUpdates → 走和全局「检查更新」按钮
完全相同的 download/install 流程,UpdateDialog 直接挂在 BetaChannelControl 内部
- 用户的第二个 feature 诉求:「在 Beta 渠道旁边一键检查 + 自动更新」 = 这个按钮
i18n 5 个 locale 加 4 个 key:betaChannelUpToDate / betaChannelUpdateNow /
betaChannelUpdateNowTitle / betaChannelChecking。
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 789aed0

`-2` 后缀让 appVersion.ts 的 IS_BETA_BUILD 仍判为 Beta,UI BETA 标签照常显示。
配本 PR 的 Beta auto-update + BetaChannelControl「立即更新」按钮,1.3.4-1 用户
切到 Beta 渠道后点检查会发现 1.3.4-2 并走 auto-update 流程一键升上来。
发布 tag:v1.3.4-2-beta-tauri。
@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit 7cdb623

@appergb
appergb merged commit 859fd53 into betaMay 17, 2026
4 checks passed
@appergb
appergb deleted the feat/beta-auto-update branch September 9, 2026 05:37
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@appergb