[fix] use numeric versions for desktop branch builds

This commit is contained in:
dijunkun
2026-10-20 21:14:38 +08:00
parent a625890b28
commit cb2ae207c4
3 changed files with 57 additions and 0 deletions
+37
View File
@@ -11,6 +11,10 @@ on:
- "!android-v*"
workflow_dispatch:
inputs:
desktop_version:
description: "Desktop version for branch builds, e.g. 1.7.2. Leave blank for 0.0.0; tags use their own version."
required: false
type: string
patch:
description: "Hotfix patch number, for example 1 or 2. Use 0 for a normal build."
required: false
@@ -29,6 +33,7 @@ env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
XMAKE_MIN_VERSION: "3.1.1"
CROSSDESK_UPDATE_PUBLIC_KEY: ${{ vars.CROSSDESK_UPDATE_PUBLIC_KEY }}
CROSSDESK_DESKTOP_VERSION: ${{ inputs.desktop_version }}
jobs:
build-linux:
@@ -57,6 +62,16 @@ jobs:
shell: bash
run: |
VERSION_REF="${GITHUB_REF##*/}"
if [[ "${GITHUB_REF}" == refs/heads/* ]]; then
VERSION_REF="${CROSSDESK_DESKTOP_VERSION:-0.0.0}"
if [[ ! "${VERSION_REF}" =~ ^v?[0-9]+(\.[0-9]+){1,3}$ ]]; then
echo "::error::desktop_version must be a numeric version such as 1.7.2"
exit 1
fi
elif [[ -n "${CROSSDESK_DESKTOP_VERSION}" ]]; then
echo "::error::desktop_version is only supported for branch builds; tags determine release versions"
exit 1
fi
VERSION_BASE="${VERSION_REF#v}"
PATCH_NUMBER="${{ github.event.inputs.patch }}"
BUILD_DATE_OVERRIDE=""
@@ -229,6 +244,16 @@ jobs:
shell: bash
run: |
VERSION_REF="${GITHUB_REF##*/}"
if [[ "${GITHUB_REF}" == refs/heads/* ]]; then
VERSION_REF="${CROSSDESK_DESKTOP_VERSION:-0.0.0}"
if [[ ! "${VERSION_REF}" =~ ^v?[0-9]+(\.[0-9]+){1,3}$ ]]; then
echo "::error::desktop_version must be a numeric version such as 1.7.2"
exit 1
fi
elif [[ -n "${CROSSDESK_DESKTOP_VERSION}" ]]; then
echo "::error::desktop_version is only supported for branch builds; tags determine release versions"
exit 1
fi
VERSION_BASE="${VERSION_REF#v}"
BUILD_DATE=$(TZ=Asia/Shanghai date +%Y%m%d)
PATCH_NUMBER="${{ github.event.inputs.patch }}"
@@ -364,6 +389,18 @@ jobs:
run: |
$ref = $env:GITHUB_REF
$version = $ref -replace '^refs/(tags|heads)/', ''
if ($ref.StartsWith("refs/heads/")) {
$version = if ([string]::IsNullOrEmpty($env:CROSSDESK_DESKTOP_VERSION)) {
"0.0.0"
} else {
$env:CROSSDESK_DESKTOP_VERSION
}
if ($version -notmatch '^v?[0-9]+(\.[0-9]+){1,3}\z') {
throw "desktop_version must be a numeric version such as 1.7.2"
}
} elseif (![string]::IsNullOrEmpty($env:CROSSDESK_DESKTOP_VERSION)) {
throw "desktop_version is only supported for branch builds; tags determine release versions"
}
$version = $version -replace '^v', ''
$version = $version -replace '/', '-'
$BUILD_DATE = ([System.TimeZoneInfo]::ConvertTimeBySystemTimeZoneId((Get-Date), "China Standard Time")).ToString("yyyyMMdd")
@@ -54,6 +54,15 @@ bool UpdateChecker::Poll(TimePoint now) {
ScheduleRetry(now);
return true;
}
// Branch names followed by a date are not application versions. Comparing
// their first digit sequence would incorrectly treat the date as a major
// version and report "up to date" for every ordinary release.
if (!IsValidAppVersion(current_version_) || !IsValidAppVersion(result->version)) {
LOG_WARN("Cannot compare invalid application versions: current={}, latest={}",
current_version_, result->version);
ScheduleRetry(now);
return true;
}
latest_ = std::move(result);
update_available_ =
IsNewerVersionWithMetadata(current_version_, latest_->version,
+11
View File
@@ -44,6 +44,17 @@ python3 -c "from pathlib import Path; p=Path('crossdesk-update-public.der').read
桌面构建工作流将公钥传给 Xmake。只有发布清单生成步骤读取私钥。
首次需要手动安装包含升级器、公钥及新安装元数据的版本。
GitHub Actions 从分支手动打包时,在 `Build and Release` 的
`Run workflow` 中填写 `desktop_version`(例如 `1.7.2`),`patch` 保持
`0`。三个桌面平台会使用同一个数字版本并追加构建日期。空着不填的分支
构建使用 `0.0.0-日期`;版本标签构建继续使用标签中的版本号。
`desktop_version` 只影响桌面安装包,不改变移动端版本。
不要使用 `vauto-update-20261020` 这类分支名作为版本号验证升级。
新版本必须增加数字版本或 patch;只改变日期不视为升级。例如先手动安装
`v1.7.2-20261020`,再验证到 `v1.7.3-20261020` 的升级。
分支手动构建只上传 Actions 构建产物,不会自动发布版本清单。
本地构建可以设置同名环境变量,或使用:
```sh