fix(release): 修复 CI 阻断与发布链路,强制版本一致性

- sysmon 采样测试改为分平台断言:此前无条件断言 working_set > 0,非 Windows 上 cargo test 必失败,v* tag 会停在测试阶段(test job 恰好跑在 ubuntu-latest)
- CI test job 补齐 GPUI 的 Linux 系统依赖,--lib --tests 让集成测试参与编译
- meta job 校验 tag 与 gpui-app/Cargo.toml 版本一致:忘 bump 会导致新版本装完仍自报旧版,客户端反复提示同一更新
- 发布脚本:--exact-match 取 tag 并强制 semver 校验(--always 会产出 v1.0.0-4-gbc9f55c 这类客户端 release_part 截断后判定不新的版本,且该 Release 会占据 /releases/latest 遮蔽真更新);Release 创建/查询/解析失败一律 exit 1,不再让 job 变绿而 OTA 通道为空
- sysmon CPU 差分基准只在真正算出结果时前移:采样间隔过近沿用上次读数,修复手点立即刷新永远读到 0%;修正 cpu_percent 注释口径(0~100,整机占比)
- README 订正发布流程:CI 实际仅出 Linux 产物;补 Release 附件(7z/裸二进制/.sha256)这一 OTA 唯一通道与命名约定;token 需 repo 写权限
This commit is contained in:
2026-09-30 10:14:18 +08:00
parent bc9f55c889
commit 2661a734ee
5 changed files with 112 additions and 26 deletions
+24 -8
View File
@@ -21,7 +21,8 @@
.PARAMETER Files
待上传文件列表。缺省时自动探测 target/release/mqttx(.exe)。
.PARAMETER Version
软件包版本。缺省时依次尝试 git describe --tags、gpui-app/Cargo.toml。
软件包版本。缺省时依次尝试当前提交的精确 tag(git describe --tags --exact-match)、
gpui-app/Cargo.toml。必须是合法 semver,否则脚本拒绝发布。
.PARAMETER Owner
覆盖 GITEA_OWNER(缺省时从 git remote origin 推断)。
.PARAMETER Repo
@@ -111,16 +112,31 @@ if (-not $Owner -or -not $Repo) {
if (-not $Owner) { Die "无法推断 owner,请用 -Owner 或 GITEA_OWNER 指定" }
if (-not $Repo) { $Repo = $Pkg }
# ── 版本:参数 > git describe > Cargo.toml ──────────────────────────────────
# ── 版本:参数 > 当前提交的精确 tag > Cargo.toml ────────────────────────────
# 严禁用 'git describe --tags --always' 兜底:它会产出 v1.0.0-4-gabc1234 这类非
# semver 描述串,据此创建的 Release 会被客户端 release_part() 截成 1.0.0 并判定
# "不比当前版本新" —— 更新永远发不出去,而且该 Release 会占据 /releases/latest,
# 把真正的更新挡在后面。
$CargoToml = Join-Path $Root "gpui-app\Cargo.toml"
$CargoVer = ""
$m = Select-String -Path $CargoToml -Pattern '^version = "(.+)"' | Select-Object -First 1
if ($m) { $CargoVer = $m.Matches[0].Groups[1].Value }
if (-not $Version) {
$Version = (git -C $Root describe --tags --always 2>$null)
$Version = (git -C $Root describe --tags --exact-match 2>$null)
if ($Version) { Write-Host "→ 版本取自当前提交的 tag: $Version" }
}
if (-not $Version) {
$m = Select-String -Path (Join-Path $Root "gpui-app\Cargo.toml") -Pattern '^version = "(.+)"' | Select-Object -First 1
if ($m) { $Version = $m.Matches[0].Groups[1].Value }
$Version = $CargoVer
if ($Version) { Write-Host "→ HEAD 无 tag,版本回退为 gpui-app/Cargo.toml: $Version" -ForegroundColor Yellow }
}
if (-not $Version) { Die "无法确定版本号" }
if (-not $Version) { Die "无法确定版本号:请用 -Version 指定(如 v1.0.1)或先给当前提交打 tag" }
$Version = $Version -replace "/", "-" # Gitea 版本段不允许 "/"
if ($Version -notmatch '^[vV]?\d+\.\d+\.\d+(-[0-9A-Za-z.]+)?$') {
Die "版本号 '$Version' 不是合法 semver(应形如 v1.0.1 或 1.0.1-rc.1)"
}
if ($CargoVer -and (($Version -replace '^[vV]', '') -ne $CargoVer)) {
Write-Host " ! 警告:版本 '$Version' 与 gpui-app/Cargo.toml ($CargoVer) 不一致" -ForegroundColor Yellow
}
# ── 默认产物 ────────────────────────────────────────────────────────────────
if (-not $Files -or $Files.Count -eq 0) {
@@ -202,8 +218,8 @@ if (-not $rel) {
Write-Host "→ 已创建 Release v$VerNum"
}
catch {
Write-Host " ! Release 创建/查询失败:$($_.Exception.Message);跳过附件上传" -ForegroundColor Yellow
return
# OTA 只认 Release 附件:这里失败等于本次发布无效,必须让调用方看到失败
Die "Release 创建/查询失败:$($_.Exception.Message)"
}
}
$releaseId = $rel.id
+25 -8
View File
@@ -62,20 +62,35 @@ REPO="${GITEA_REPO:-$(remote_owner_repo | tail -1 || true)}"
[ -n "${OWNER:-}" ] || die "无法推断 GITEA_OWNER,请显式设置"
[ -n "${REPO:-}" ] || REPO="$PKG"
# ── 版本:参数 > git describe > Cargo.toml ───────────────────────────────────
# ── 版本:参数 > 当前提交的精确 tag > Cargo.toml ─────────────────────────────
# 严禁用 'git describe --tags --always' 兜底:它会产出 v1.0.0-4-gabc1234 这类非
# semver 描述串,据此创建的 Release 会被客户端 release_part() 截成 1.0.0 并判定
# "不比当前版本新" —— 更新永远发不出去,而且该 Release 会占据 /releases/latest,
# 把真正的更新挡在后面。
FILES=()
for arg in "$@"; do
if [ -f "$arg" ]; then FILES+=("$arg"); else VERSION="$arg"; fi
done
CARGO_VER="$(grep -m1 '^version' "$ROOT/gpui-app/Cargo.toml" | cut -d'"' -f2)"
if [ -z "${VERSION:-}" ]; then
VERSION="$(git -C "$ROOT" describe --tags --always 2>/dev/null || true)"
VERSION="$(git -C "$ROOT" describe --tags --exact-match 2>/dev/null || true)"
[ -n "$VERSION" ] && echo "→ 版本取自当前提交的 tag: $VERSION"
fi
if [ -z "${VERSION:-}" ]; then
VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/gpui-app/Cargo.toml" | head -1)"
VERSION="$CARGO_VER"
[ -n "$VERSION" ] && echo "→ HEAD 无 tag,版本回退为 gpui-app/Cargo.toml: $VERSION" >&2
fi
[ -n "${VERSION:-}" ] || die "无法确定版本号"
# Gitea 版本段不允许 "/",tag 形如 v1.0.0-3-gabc123 时规范化
[ -n "${VERSION:-}" ] || die "无法确定版本号:请显式传入(如 v1.0.1)或先给当前提交打 tag"
# Gitea 版本段不允许 "/"
VERSION="${VERSION//\//-}"
# semver 校验:非 semver 版本会让 OTA 静默失效(见上方注释),宁可直接拒绝发布
if ! printf '%s' "$VERSION" | grep -Eq '^[vV]?[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?$'; then
die "版本号 '$VERSION' 不是合法 semver(应形如 v1.0.1 或 1.0.1-rc.1)"
fi
# 与编译期版本比对:不一致时客户端装完新版本仍自报旧版本号,会反复提示同一更新
if [ -n "$CARGO_VER" ] && [ "${VERSION#v}" != "$CARGO_VER" ] && [ "${VERSION#V}" != "$CARGO_VER" ]; then
echo " ! 警告:版本 '$VERSION' 与 gpui-app/Cargo.toml ($CARGO_VER) 不一致" >&2
fi
# ── 默认产物 ────────────────────────────────────────────────────────────────
if [ "${#FILES[@]}" -eq 0 ]; then
@@ -174,15 +189,17 @@ if [ "$code" = "404" ]; then
if [ "$code" != "201" ]; then
echo " ! Release 创建失败 (HTTP $code),跳过附件上传" >&2
cat "$STAGE/rel.json" >&2 || true
exit 0
# OTA 只认 Release 附件:这里失败等于本次发布无效,必须让调用方看到失败,
# 而不是把 job 变绿、让"发布成功"与"用户能收到更新"脱钩。
exit 1
fi
elif [ "$code" != "200" ]; then
echo " ! 查询 Release 失败 (HTTP $code),跳过附件上传" >&2
exit 0
exit 1
fi
# 顶层 "id" 是首个出现的 id 字段
RELEASE_ID="$(sed -n 's/.*"id":[[:space:]]*\([0-9][0-9]*\).*/\1/p' "$STAGE/rel.json" | head -1)"
[ -n "$RELEASE_ID" ] || { echo " ! 无法解析 Release id,跳过附件上传" >&2; exit 0; }
[ -n "$RELEASE_ID" ] || { echo " ! 无法解析 Release id,跳过附件上传" >&2; exit 1; }
echo "→ Release v${VER_NUM} (id=$RELEASE_ID),上传附件…"
for f in "${FILES[@]}"; do