Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Agent 笔记:AutoBuild 更新源与预发布版本号

状态:提议中

## 先说结论

桌面端客户端已经能从 AutoBuild 渠道检查更新(见 [更新渠道与更新对话框](../../implemented/feature/2026-11-15-desktop-update-channels-and-dialog.md)),但 `autobuild.json` 还没有发布。原因是每个 AutoBuild 包都沿用 `desktop/viva.toml` 的版本号(如 `0.7.0`),同一渠道里前后两次构建的版本相同,客户端看不出哪个更新。

本提案让 AutoBuild 的版本号带上预发布后缀 `0.7.0-autobuild.<UTC 时间>`,再像正式版一样签名发布 `autobuild.json`。这一步要先改 Lithe-IDEA/viva fork:Viva 的打包清单(manifest)现在只接受纯数字版本号。fork 的改动必须同时向上游 vivaui/viva 提 PR,并由维护者授权后才做。

## 问题

1. **同一渠道版本号相同。** `scripts/ci/desktop-autobuild/package-autobuild.sh` 用 `viva.toml` 的版本打包。客户端拿运行版本和 `autobuild.json` 比较,两次构建都是 `0.7.0`,永远不会提示更新。
2. **Viva 打包拒绝预发布版本号。** fork 的 `tools/manifest/manifest.go` 用 `^[0-9]+(\.[0-9]+){0,2}$` 校验版本,`viva package` 不接受 `0.7.0-autobuild.20261116100000`。
3. **各平台的版本字段格式不同。**
- macOS:`update/install_darwin.go` 要求包内 `CFBundleShortVersionString` 与更新源版本完全一致;Apple 又要求这个字段和 `CFBundleVersion` 是点分数字。
- Windows:`VERSIONINFO` 的文件版本只能是四段数字。
- deb 和 rpm 对 `-` 有各自的含义:deb 用 `~` 表示“早于”,rpm 的 `Version` 不能含 `-`。
4. 比较本身没问题:Viva 的 `update.Compare` 已按 SemVer 2.0.0 排预发布版本,`0.7.0-autobuild.20261116` 早于 `0.7.0`,同一后缀按时间排序。

## 提案

### 1. Viva fork:清单接受 SemVer 预发布版本,按格式映射

- 清单版本允许 `MAJOR.MINOR.PATCH-<预发布>`,预发布部分按 SemVer 规则校验;不带后缀的版本行为不变。
- 每种格式写自己能接受的字段,同时把完整版本记在包里,供安装器核对:
- macOS:`CFBundleShortVersionString` 写基础版本 `0.7.0`,`CFBundleVersion` 写数字构建号;完整版本写入单独的 Info.plist 键,`install_darwin.go` 改为核对这个键(缺省时退回 `CFBundleShortVersionString`,兼容旧包)。
- Windows:文件版本写 `0.7.0.<构建号>`,产品版本字符串写完整版本。
- deb 写 `0.7.0~autobuild.<时间>`;rpm 的 `Version` 写 `0.7.0`,`Release` 写 `autobuild.<时间>`。
- 先合进 fork `main`,同一分支向上游 vivaui/viva 提 PR;然后升级 `desktop/go.mod` 的 `replace`。Lithe 不在应用层改写打包结果来绕过。

### 2. Lithe:AutoBuild 版本号和更新源

- `package-autobuild.sh` 把版本设为 `<viva.toml 版本>-autobuild.<UTC YYYYMMDDHHMMSS>`,时间取工作流 `prepare` 的同一个时间戳,所有平台一致。
- `scripts/ci/desktop-release/publish-update-feed.sh` 增加渠道参数,AutoBuild 写 `autobuild.json`、`.sig` 和 `autobuild.notes.md`,并发组 `desktop-update-feed-autobuild`。私钥同样只交给发布更新源的任务。
- **增量补丁的基线**是当前 `autobuild.json` 提供的版本。滚动 release `desktop-AutoBuild` 会被新构建覆盖,所以必须在覆盖之前下载旧归档,并对照更新源摘要校验;取不到就只发布完整包。
- **日志**由上一次 AutoBuild commit 到本次 commit 之间的 first-parent 提交(PR 标题和编号)生成,超长截断并附 compare 链接。

## 考虑过的备选方案

### 版本号加第四段数字(`0.7.0.<构建号>`)

不用改预发布语义,Windows 也天然接受。

不采用:清单只允许三段,`update.Compare` 也不认第四段;这种版本还会比同号正式版“更新”,和“AutoBuild 朝着下一个正式版构建”的含义相反。

### 每次 AutoBuild 提升 PATCH(`0.7.<时间>`)

纯数字,Viva 不用改。

不采用:占用正式版的版本空间,`0.7.20261116` 会大于以后所有 `0.7.x` 正式版,跨渠道“等下一个正式版”的规则失效。

### Lithe 在 `viva package` 之后改写版本字段

不用等 fork。

不采用:改写会破坏 macOS 签名和 Windows 签名,也违反“Viva 的问题在 fork 修复,不在 Lithe 写绕过代码”的规则。

## 验收标准

- `viva package` 能打包 `0.7.0-autobuild.<时间>`,macOS、Windows、deb、rpm 各自的版本字段合法,签名和公证通过。
- 连续两次 AutoBuild 之后,装着前一次构建的客户端能发现、下载(含增量补丁)并安装后一次构建;补丁不可用时回退完整包。
- AutoBuild 用户切回正式版时,“等下一个正式版”只在更高的正式版出现时提示。
- `autobuild.notes.md` 首行版本与 `autobuild.json` 一致,对话框显示这次构建的提交列表。
- `scripts/desktop/verify/verify-runtime-bundle-immutability.sh` 通过。

## 风险

- **macOS 版本核对改动影响已发布的包**:安装器新逻辑必须兼容没有新 Info.plist 键的旧包,否则正式版用户也更新不了。
- **上游不接受映射方案**:按 fork 维护规则以上游为准;在上游方案确定前,fork 补丁要保持小而可替换。
- **滚动 release 的旧字节**:发布顺序一旦颠倒(先覆盖再下载),这一轮只能发布完整包。

## 适用范围

- `desktop/viva.toml`
- `desktop/go.mod`
- `scripts/ci/desktop-autobuild/`
- `scripts/ci/desktop-release/publish-update-feed.sh`
- `.github/workflows/desktop-autobuild.yml`
18 changes: 18 additions & 0 deletions .agents/skills/release-lithe/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,24 @@ before committing the notes.
- Check the comparison range, current platform requirements, bundled tools,
signing status, updater availability, and known issues against the target
commit and release configuration.
- For a desktop release, check the in-app update feed it publishes: the
`update-feed` job of `desktop-release.yml` runs
`scripts/ci/desktop-release/publish-update-feed.sh` once the release holds
the packages. The repository needs the Actions secret `VIVA_UPDATE_KEY`, the
Ed25519 private key from `viva update-keygen`, which only that job receives
and which is never committed. It also needs the variable
`LITHE_UPDATE_PUBLIC_KEYS`, the matching public keys separated by commas,
which every package carries. One of those public keys belongs to a backup
private key kept offline, outside GitHub. A lost key is replaced by the
backup. A leaked key must be removed from the variable and followed by a
release signed with the remaining key, because clients accept any key they
carry and adding a key does not revoke one. Without the secret the job
publishes nothing and installed copies are not offered the release; without
the variable the packages cannot check for updates at all. The update dialog shows
`docs/releases/v<version>.md` as what the update changes, so the notes must
read well there too. A feed that already offers a later version is left as
it is. See
`.agents/notes/implemented/feature/2026-11-15-desktop-update-channels-and-dialog.md`.
- Run `actionlint` after changing a GitHub Actions workflow. Run any focused
packaging or manifest checks required by `develop-lithe` for other release
changes.
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/desktop-autobuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ jobs:
WINDOWS_CERTIFICATE_PASSWORD: ${{ matrix.os == 'windows' && secrets.WINDOWS_SIGNING_CERTIFICATE_PASSWORD || '' }}
WINDOWS_TIMESTAMP_URL: ${{ matrix.os == 'windows' && secrets.WINDOWS_TIMESTAMP_SERVER || '' }}
DESKTOP_ARCH: ${{ matrix.arch }}
# Every platform records the same build time and commit. The feed keys are public; the
# private signing key never reaches a packaging runner.
LITHE_BUILD_TIME: ${{ needs.prepare.outputs.timestamp }}
LITHE_BUILD_COMMIT: ${{ needs.prepare.outputs.sha }}
LITHE_UPDATE_PUBLIC_KEYS: ${{ vars.LITHE_UPDATE_PUBLIC_KEYS }}
run: bash scripts/ci/desktop-autobuild/package-autobuild.sh "$DESKTOP_ARCH"

- name: Upload the packages
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/desktop-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ jobs:
bash -n scripts/desktop/build-desktop-core.sh
bash -n scripts/desktop/desktop-go.sh
bash -n scripts/desktop/package-desktop.sh
bash -n scripts/desktop/build-viva-tool.sh
bash -n scripts/desktop/perf/editor-bench.sh
bash -n scripts/ci/desktop-release/package-release.sh
bash -n scripts/ci/desktop-release/resolve-release-version.sh
bash -n scripts/ci/desktop-release/publish-update-feed.sh
bash -n scripts/ci/desktop-autobuild/package-autobuild.sh
bash -n scripts/ci/desktop-autobuild/publish-autobuild.sh
zsh -n scripts/desktop/generate-desktop-icons.sh
Expand All @@ -86,9 +88,11 @@ jobs:
scripts/desktop/build-desktop-core.sh \
scripts/desktop/desktop-go.sh \
scripts/desktop/package-desktop.sh \
scripts/desktop/build-viva-tool.sh \
scripts/desktop/perf/editor-bench.sh \
scripts/ci/desktop-release/package-release.sh \
scripts/ci/desktop-release/resolve-release-version.sh \
scripts/ci/desktop-release/publish-update-feed.sh \
scripts/ci/desktop-autobuild/package-autobuild.sh \
scripts/ci/desktop-autobuild/publish-autobuild.sh

Expand Down Expand Up @@ -124,7 +128,7 @@ jobs:
scripts/desktop/perf/editor-perf-report.test.mjs \
scripts/ci/cancel-closed-pr-runs/cancel-closed-pr-runs.test.mjs \
scripts/ci/desktop-ci/verify-ci-gate.test.mjs
node --test --test-concurrency=1 scripts/ci/desktop-autobuild/package-autobuild.test.mjs scripts/ci/common/desktop-packages.test.mjs scripts/ci/desktop-release/package-release.test.mjs scripts/ci/desktop-release/resolve-release-version.test.mjs
node --test --test-concurrency=1 scripts/ci/desktop-autobuild/package-autobuild.test.mjs scripts/ci/common/desktop-packages.test.mjs scripts/ci/desktop-release/package-release.test.mjs scripts/ci/desktop-release/resolve-release-version.test.mjs scripts/ci/desktop-release/publish-update-feed.test.mjs

linux-test:
name: Vet and test on Linux
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/desktop-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
matrix: ${{ steps.packages.outputs.matrix }}
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
timestamp: ${{ steps.time.outputs.timestamp }}

steps:
- name: Check out source
Expand All @@ -52,6 +53,11 @@ jobs:
REQUESTED_VERSION: ${{ github.event_name == 'workflow_dispatch' && inputs.version || github.ref_name }}
run: bash scripts/ci/desktop-release/resolve-release-version.sh "$REQUESTED_VERSION"

# Every platform records the same build time.
- name: Record the build time
id: time
run: printf 'timestamp=%s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"

build:
name: Package ${{ matrix.os }} ${{ matrix.arch }}
needs: prepare
Expand All @@ -60,6 +66,12 @@ jobs:
defaults:
run:
shell: bash
# What About and the updater show (package-desktop.sh). The feed keys are public; the
# private signing key never reaches a packaging runner.
env:
LITHE_BUILD_TIME: ${{ needs.prepare.outputs.timestamp }}
LITHE_BUILD_COMMIT: ${{ github.sha }}
LITHE_UPDATE_PUBLIC_KEYS: ${{ vars.LITHE_UPDATE_PUBLIC_KEYS }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
Expand Down Expand Up @@ -226,3 +238,46 @@ jobs:
exit 1
fi
gh release upload "$RELEASE_TAG" "${release_files[@]}" --repo "$GITHUB_REPOSITORY" --clobber

# The stable feed is signed apart from the packaging and the release: this job alone is given
# the private key, and it runs once the release holds the packages the feed points to.
update-feed:
name: Publish the stable update feed
if: github.event_name != 'workflow_dispatch' || inputs.publish
needs:
- prepare
- publish
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
# Two releases never write the feed at once.
concurrency:
group: desktop-update-feed-stable
cancel-in-progress: false

steps:
- name: Check out source
uses: actions/checkout@v7

# viva feed is built from the fork desktop/go.mod pins.
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: desktop/go.mod
cache-dependency-path: desktop/go.sum

- name: Download the packages
uses: actions/download-artifact@v8
with:
pattern: desktop-*
path: dist
merge-multiple: true

- name: Sign and publish the feed, its delta updates and notes
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.prepare.outputs.tag }}
DESKTOP_VERSION: ${{ needs.prepare.outputs.version }}
VIVA_UPDATE_KEY: ${{ secrets.VIVA_UPDATE_KEY }}
run: bash scripts/ci/desktop-release/publish-update-feed.sh dist
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ DerivedData/

# Generated by scripts/desktop/package-desktop.sh for the lithe_bundled_helper build tag.
desktop/internal/idehelp/lithe-mcp.bin
# Generated by scripts/desktop/package-desktop.sh for the lithe_package_info build tag.
desktop/internal/buildinfo/package_info.go
77 changes: 67 additions & 10 deletions desktop/internal/buildinfo/update.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,75 @@
package buildinfo

// The update feed a release build checks, set at link time
// (-X github.com/1lck/Lithe-IDEA/desktop/internal/buildinfo.UpdateFeedURL=...). A build
// without them does not check for updates: development and local builds never replace
// themselves.
import "strings"

// Lithe updates from one of two channels: the stable releases, which go through the release
// process, and AutoBuild, built from main every day. Each has its own signed feed. The channel a
// build was packaged for, when and from which commit, and the keys the feeds are signed with are
// set by package_info.go, which scripts/desktop/package-desktop.sh generates for the
// lithe_package_info build tag and removes once it has packaged (viva package takes no -ldflags).
// A build without a channel, a development or local build, never replaces itself.
const (
ChannelStable = "stable"
ChannelAutoBuild = "autobuild"
)

// Channels are the update channels, in the order the settings list them.
var Channels = []string{ChannelStable, ChannelAutoBuild}

var (
// UpdateFeedURL is the HTTPS address of the signed latest.json.
UpdateFeedURL string
// UpdatePublicKeys are the Ed25519 keys the feed may be signed with, base64,
// separated by commas, so a key can be rotated.
// Channel is the channel the build was packaged for: ChannelStable or ChannelAutoBuild.
Channel string
// BuildTime is when the build was packaged, in RFC 3339 and UTC.
BuildTime string
// Commit is the Git commit the build was packaged from.
Commit string
// UpdatePublicKeys are the Ed25519 keys a feed may be signed with, base64, separated by
// commas, so a key can be rotated. Both channels and every feed address the user sets are
// checked against them.
UpdatePublicKeys string
// UpdateChannel is the release channel the build follows, such as "stable".
UpdateChannel string
// StableFeedURL and AutoBuildFeedURL are the default feeds of the channels, on the official
// repository's desktop-update-feed release. A fork that signs its own feeds sets them.
StableFeedURL = "https://github.com/1lck/Lithe-IDEA/releases/download/desktop-update-feed/stable.json"
AutoBuildFeedURL = "https://github.com/1lck/Lithe-IDEA/releases/download/desktop-update-feed/autobuild.json"
// DownloadsURL is where a user downloads Lithe by hand, for an installation that cannot
// update itself.
DownloadsURL = "https://github.com/1lck/Lithe-IDEA/releases"
)

// UpdateApp is the identifier the feed and the installed application carry.
const UpdateApp = "app.lithe.viva"

// InstalledChannel is the channel the running build was packaged for, empty for a development
// or local build, which does not update.
func InstalledChannel() string {
if Development {
return ""
}
return KnownChannel(Channel)
}

// KnownChannel is channel when it names one of the channels, else empty.
func KnownChannel(channel string) string {
switch channel = strings.TrimSpace(channel); channel {
case ChannelStable, ChannelAutoBuild:
return channel
}
return ""
}

// ReleaseBase is version without its pre-release and build suffixes: the release an AutoBuild
// version, 0.7.0-autobuild.<time>, builds towards. An empty version stays empty.
func ReleaseBase(version string) string {
if cut := strings.IndexAny(version, "-+"); cut >= 0 {
version = version[:cut]
}
return version
}

// DefaultFeedURL is the feed a channel reads unless the user set another.
func DefaultFeedURL(channel string) string {
if channel == ChannelAutoBuild {
return AutoBuildFeedURL
}
return StableFeedURL
}
Loading
Loading