diff --git a/AGENTS.md b/AGENTS.md
index 26d2a6b..4745993 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -118,3 +118,9 @@ macOS 是正式交付的最大不确定性。不能把存在 API 或实验原型
- Apple 关于受管理 entitlement 申请的官方答复:https://developer.apple.com/forums/thread/802495
上述为方案记录时查阅的资料;正式实施前应重新核实平台 API、授权、签名与分发要求。
+
+## 发布打包约定
+
+每次新发布打包将版本号的补丁位增加 1(例如 0.2.0 → 0.2.1),同步 Cargo 工作区与锁文件、Avalonia、Flutter 和安装包版本。Windows 必须生成 Setup.exe,Linux 采用 deb 安装包;普通开发编译不增加版本。同一版本的 Windows/Linux 安装包只递增一次,另一平台使用复用版本选项。打包失败后重试复用已分配版本,避免重复递增。发布产物不包含私有凭据。
+
+`scripts/release-version.py` 为共享版本分配脚本(Python)。Windows 使用 `scripts/build-installers.ps1` 自动递增并重建后端与桌面安装包;同一次发布的重试或第二平台使用 `-ReuseVersion`。Linux 使用 `bash scripts/build-linux-packages.sh` 自动递增,另一平台已分配版本时设置 `ADS_REUSE_VERSION=1`,须提供该版本重新构建的原生产物。
diff --git a/README.md b/README.md
index c369dea..b04ee29 100644
--- a/README.md
+++ b/README.md
@@ -233,3 +233,9 @@ Linux 原生虚拟 USB 已在 Ubuntu 实机通过 CLI 验证,部署和权限
Flutter 管理中心已迁移 Cupertino UI,设备按电脑归属分组,支持按电脑名搜索;运行日志按天保存并按大小滚动,路径及策略见 [Flutter 使用说明](flutter_manager/README.md)。
桌面日志界面提供“打开日志文件夹”。Avalonia 与 Flutter 均按天保存日志,单文件达到 5 MiB 后滚动,每日最多 5 份,保留最近 14 天。设备列表显示所属电脑及 Agent。Windows 安装包默认安装到 `%LOCALAPPDATA%/Programs/TongTongStudio/ADS-{Edition}`;用户配置和日志位置保持兼容。升级保持原 AppId,安装目录不再自动沿用旧的 TTSTD 路径。
+
+## 发布打包约定
+
+每次新发布打包将版本号的补丁位增加 1(例如 0.2.0 → 0.2.1),同步 Cargo 工作区与锁文件、Avalonia、Flutter 和安装包版本。Windows 必须生成 Setup.exe,Linux 采用 deb 安装包;普通开发编译不增加版本。同一版本的 Windows/Linux 安装包只递增一次,另一平台使用复用版本选项。打包失败后重试复用已分配版本,避免重复递增。发布产物不包含私有凭据。
+
+`scripts/release-version.py` 为共享版本分配脚本(Python)。Windows 使用 `scripts/build-installers.ps1` 自动递增并重建后端与桌面安装包;同一次发布的重试或第二平台使用 `-ReuseVersion`。Linux 使用 `bash scripts/build-linux-packages.sh` 自动递增,另一平台已分配版本时设置 `ADS_REUSE_VERSION=1`,须提供该版本重新构建的原生产物。
diff --git a/scripts/build-installers.ps1 b/scripts/build-installers.ps1
index 2d4ca40..4846338 100644
--- a/scripts/build-installers.ps1
+++ b/scripts/build-installers.ps1
@@ -1,7 +1,8 @@
param(
[ValidateSet('All','Avalonia','Flutter')][string]$Edition='All',
[string]$Compiler,
- [switch]$SkipBuild
+ [switch]$SkipBuild,
+ [switch]$ReuseVersion
)
$ErrorActionPreference='Stop'
$root=Split-Path $PSScriptRoot -Parent
@@ -10,8 +11,15 @@ if (-not $Compiler) {
$Compiler=$candidates | Where-Object { Test-Path -LiteralPath $_ } | Select-Object -First 1
}
if (-not $Compiler) { throw 'Install Inno Setup 6/7 or specify -Compiler path/to/ISCC.exe' }
-$version=[regex]::Match((Get-Content (Join-Path $root 'Cargo.toml') -Raw),'(?m)^version = "([0-9.]+)"').Groups[1].Value
-if (-not $version) { throw 'Workspace version missing' }
+if ($SkipBuild -and -not $ReuseVersion) { throw 'SkipBuild requires ReuseVersion; new releases must rebuild their binaries' }
+$versionArgs=@((Join-Path $PSScriptRoot 'release-version.py'))
+if ($ReuseVersion) { $versionArgs+='--reuse' }
+$version=(& python @versionArgs).Trim()
+if ($LASTEXITCODE) { throw 'Release version update failed' }
+if (-not $SkipBuild) {
+ & (Join-Path $PSScriptRoot 'build.ps1')
+ if ($LASTEXITCODE) { throw 'Backend build failed' }
+}
$output=Join-Path $root 'bin/installers'
New-Item -ItemType Directory -Force -Path $output | Out-Null
foreach ($name in @('Avalonia','Flutter')) {
diff --git a/scripts/build-linux-packages.sh b/scripts/build-linux-packages.sh
index 6957b10..2d547d1 100644
--- a/scripts/build-linux-packages.sh
+++ b/scripts/build-linux-packages.sh
@@ -4,9 +4,14 @@ root=$(cd -- "$(dirname -- "$0")/.." && pwd)
mode=${1:-all}
case "$mode" in all|avalonia|agent|server|flutter) ;; *) echo 'Usage: build-linux-packages.sh [all|avalonia|agent|server|flutter]' >&2; exit 2;; esac
case "$(uname -m)" in x86_64) arch=amd64; rid=linux-x64;; aarch64) arch=arm64; rid=linux-arm64;; *) echo 'Unsupported architecture' >&2; exit 1;; esac
-version=$(sed -n 's/^version = "\([0-9.]*\)"/\1/p' "$root/Cargo.toml" | head -1 | tr -d '\r')
-[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit 1
command -v dpkg-deb >/dev/null
+# One patch increment per release; use ADS_REUSE_VERSION=1 for its other platform.
+version_args=()
+if [[ "${ADS_REUSE_VERSION:-0}" == 1 ]]; then version_args+=(--reuse); fi
+version=$(python3 "$root/scripts/release-version.py" "${version_args[@]}")
+if [[ "${ADS_REUSE_VERSION:-0}" != 1 ]]; then
+ (cd "$root" && cargo build --release --locked -p ads-agent -p ads-client -p adsctl -p ads-usb)
+fi
output="$root/bin/installers/linux"; mkdir -p "$output"
stage=$(mktemp -d)
trap 'rm -rf -- "$stage"' EXIT
@@ -28,7 +33,7 @@ package() {
find "$payload" -type d -exec chmod 755 {} +
find "$payload" -type f -exec chmod 644 {} +
check_elf "$payload/$exe"; chmod 755 "$payload/$exe"
- for tool in ads-agent ads-client adsctl ads-server ads-relay; do
+ for tool in ads-agent ads-client adsctl ads-usb ads-server ads-relay; do
if [[ -f "$payload/$tool" ]]; then check_elf "$payload/$tool"; chmod 755 "$payload/$tool"; fi
done
printf '#!/bin/sh\nexec /opt/ttstd/%s/%s "$@"\n' "$name" "$exe" > "$tree/usr/bin/$name"
@@ -43,7 +48,6 @@ package() {
printf 'Package: %s\nVersion: %s\nArchitecture: %s\nMaintainer: TongTong Studio\nDepends: %s\nDescription: ADS %s remote Android management\n' "$name" "$version" "$arch" "$deps" "$kind" > "$tree/DEBIAN/control"
chmod 755 "$tree/DEBIAN"; chmod 644 "$tree/DEBIAN/control"
dpkg-deb --root-owner-group --build "$tree" "$output/${name}_${version}_${arch}.deb"
- tar -czf "$output/${name}-${version}-${rid}.tar.gz" -C "$payload" .
}
if [[ "$mode" == all || "$mode" == agent ]]; then
mkdir -p "$stage/agent-source"
@@ -61,14 +65,14 @@ if [[ "$mode" == all || "$mode" == avalonia ]]; then
(cd "$root/desktop" && dotnet publish Ads.Desktop -c Release -r "$rid" --self-contained true -o "$source" --nologo)
fi
mkdir -p "$stage/avalonia-source"; cp -a "$source/." "$stage/avalonia-source/"
- for tool in ads-agent adsctl ads-client; do cp "$backend/$tool" "$stage/avalonia-source/"; done
+ for tool in ads-agent adsctl ads-client ads-usb; do cp "$backend/$tool" "$stage/avalonia-source/"; done
package avalonia Ads.Desktop "$stage/avalonia-source" 'libc6 (>= 2.31), libgcc-s1, libstdc++6, libx11-6, libice6, libsm6, libfontconfig1, libfreetype6, libicu76 | libicu74 | libicu72 | libicu70, libssl3t64 | libssl3, zlib1g, adb, scrcpy'
fi
if [[ "$mode" == flutter ]]; then
: "${ADS_FLUTTER_BUNDLE:?Provide a native Linux Flutter release bundle}"
mkdir -p "$stage/flutter-source"; cp -a "$ADS_FLUTTER_BUNDLE/." "$stage/flutter-source/"
- for tool in ads-agent adsctl ads-client; do cp "$backend/$tool" "$stage/flutter-source/"; done
+ for tool in ads-agent adsctl ads-client ads-usb; do cp "$backend/$tool" "$stage/flutter-source/"; done
package flutter ads_manager "$stage/flutter-source" 'libc6 (>= 2.31), libstdc++6, libgtk-3-0, libayatana-appindicator3-1, adb, scrcpy'
fi
-(cd "$output" && sha256sum ./*.deb ./*.tar.gz > SHA256SUMS)
+(cd "$output" && sha256sum ./*.deb > SHA256SUMS)
echo "Linux packages: $output"
diff --git a/scripts/release-version.py b/scripts/release-version.py
new file mode 100644
index 0000000..2224106
--- /dev/null
+++ b/scripts/release-version.py
@@ -0,0 +1,33 @@
+"""Advance the shared release version once, or read it for another platform."""
+import argparse
+import re
+from pathlib import Path
+
+
+def update(root, reuse=False):
+ cargo = root / "Cargo.toml"
+ content = cargo.read_text(encoding="utf-8")
+ old = re.search(r'^version = "(\d+\.\d+\.\d+)"', content, re.M)[1]
+ if reuse:
+ return old
+ major, minor, patch = map(int, old.split("."))
+ version = f"{major}.{minor}.{patch + 1}"
+ changes = {cargo: content.replace(f'version = "{old}"', f'version = "{version}"', 1)}
+ lock = root / "Cargo.lock"
+ changes[lock] = re.sub(r'(name = "ads-[^"\n]+"\nversion = ")[^"]+("\n)', lambda m: m[1] + version + m[2], lock.read_text(encoding="utf-8"))
+ pub = root / "flutter_manager/pubspec.yaml"
+ changes[pub] = re.sub(r'^version: ([^\n]+)', lambda m: f"version: {version}+{int(m[1].split('+')[1]) + 1}", pub.read_text(encoding="utf-8"), flags=re.M)
+ project = root / "desktop/Ads.Desktop/Ads.Desktop.csproj"
+ text = project.read_text(encoding="utf-8")
+ text = re.sub(r'[^<]+', '', text)
+ changes[project] = text.replace('', f'{version}', 1)
+ for path, text in changes.items():
+ path.write_text(text, encoding="utf-8", newline="\n")
+ return version
+
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--reuse", action="store_true", help="Use the version already allocated to this cross-platform release")
+ args = parser.parse_args()
+ print(update(Path(__file__).resolve().parent.parent, args.reuse))