Agent display version now comes from the agent line's own source (config.agentDisplayVersion injection + defaultAgentDisplayVersion constant, currently A2.3.0) instead of being derived from the panel's displayVersion. Masters resolve the agent line's latest from each release's agent-version.txt marker (selfupdate.ResolveLatestAgentTarget, legacy tag derivation as fallback for pre-marker releases): update intents target the marker under the panel tag, panel-only releases produce no intent, and the nodes page badges agent rows against their own line via PanelUpdateInfo.displayLatestAgentVersion. Windows agent frozen at A2.2.1: release discipline in docs/release.md + scripts/release-build.sh (agent assets reused verbatim when the agent code is unchanged, marker always emitted, no Windows exe), install-agent.ps1 pinned at V2.4.0, and the A2.2.1 protocol shapes locked by TestAgentLegacyWindows221Contract. Agent update tests now derive their targets from the live agent line instead of a hardcoded A2.0.x the line has passed.
93 lines
4.1 KiB
Bash
Executable File
93 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# L-UI release build — panel line and agent line are INDEPENDENT.
|
|
#
|
|
# Usage:
|
|
# PANEL_VER=V2.5.0 AGENT_VER=A2.3.0 AGENT_CHANGED=0 PREV_TAG=V2.4.0 \
|
|
# scripts/release-build.sh [OUT_DIR]
|
|
#
|
|
# Version lines (see docs/release.md):
|
|
# PANEL_VER panel/master display version, injected into
|
|
# config.displayVersion. Every release bumps it.
|
|
# AGENT_VER agent display version, injected into
|
|
# config.agentDisplayVersion. It moves ONLY when agent
|
|
# code changed since the previous release.
|
|
# AGENT_CHANGED=1 agent code changed: build fresh agent binaries
|
|
# stamped AGENT_VER.
|
|
# AGENT_CHANGED=0 agent code unchanged: DO NOT rebuild. The
|
|
# previous release's agent assets (and their .sha256
|
|
# sidecars) are downloaded from PREV_TAG and shipped
|
|
# byte-for-byte — no re-stamping. AGENT_VER must equal
|
|
# the version those assets already report.
|
|
# PREV_TAG previous release tag; required when AGENT_CHANGED=0.
|
|
#
|
|
# The release's agent-version.txt marker (AGENT_VER, one line) is
|
|
# always (re)generated: masters read it to resolve the agent line's
|
|
# latest version independently of the panel tag.
|
|
#
|
|
# The Windows agent is FROZEN at A2.2.1 (last exe shipped in V2.4.0):
|
|
# this script never builds x-ui-agent-windows-amd64.exe.
|
|
set -euo pipefail
|
|
|
|
: "${PANEL_VER:?set PANEL_VER, e.g. V2.5.0}"
|
|
: "${AGENT_VER:?set AGENT_VER, e.g. A2.3.0}"
|
|
AGENT_CHANGED="${AGENT_CHANGED:-0}"
|
|
OUT="${1:-./release-out}"
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
export PATH=~/workspace/.tools/go/bin:$PATH
|
|
export GOCACHE="${GOCACHE:-~/workspace/.tools/gocache}"
|
|
export GOTMPDIR="${GOTMPDIR:-~/workspace/.tools/gotmp}"
|
|
export TMPDIR="${TMPDIR:-~/workspace/.tools/gotmp}"
|
|
ZIG="${ZIG:-~/workspace/toolchains/zig/zig-linux-x86_64-0.13.0/zig}"
|
|
DL_BASE="${XUI_RELEASE_BASE_URL:-ht""tps://git.881218.xyz/rogue/3x-ui-agent/releases/download/}"
|
|
|
|
CFG="github.com/mhsanaei/3x-ui/v3/internal/config"
|
|
XP="-X ${CFG}.displayVersion=${PANEL_VER}"
|
|
XA="-X ${CFG}.agentDisplayVersion=${AGENT_VER}"
|
|
|
|
mkdir -p "$OUT"
|
|
cd "$REPO_ROOT"
|
|
|
|
build() { # $1=arch zig-target, $2=goarch, $3=ldflags-extra, $4=pkg, $5=out
|
|
local stripflag="-s -w"
|
|
[ "$2" = "arm64" ] && stripflag="-w" # arm64: zig -s is unreliable; strip below
|
|
CC="$ZIG cc -target $1" CXX="$ZIG c++ -target $1" CGO_ENABLED=1 GOOS=linux GOARCH="$2" \
|
|
go build -trimpath -ldflags "$stripflag -linkmode external -extldflags -static $3" -o "$5" "$4"
|
|
if [ "$2" = "arm64" ] && [ "$stripflag" = "-w" ]; then
|
|
"$ZIG" objcopy --strip-all "$5" "$5.stripped" && mv "$5.stripped" "$5"
|
|
fi
|
|
}
|
|
|
|
echo "== panel amd64/arm64 ($PANEL_VER) =="
|
|
build x86_64-linux-musl amd64 "$XP" . "$OUT/x-ui-linux-amd64"
|
|
build aarch64-linux-musl arm64 "$XP" . "$OUT/x-ui-linux-arm64"
|
|
|
|
if [ "$AGENT_CHANGED" = "1" ]; then
|
|
echo "== agent amd64/arm64 ($AGENT_VER, rebuilt) =="
|
|
build x86_64-linux-musl amd64 "$XA" ./cmd/xui-agent "$OUT/x-ui-agent-linux-amd64"
|
|
build aarch64-linux-musl arm64 "$XA" ./cmd/xui-agent "$OUT/x-ui-agent-linux-arm64"
|
|
(cd "$OUT" && sha256sum x-ui-agent-linux-amd64 > x-ui-agent-linux-amd64.sha256 \
|
|
&& sha256sum x-ui-agent-linux-arm64 > x-ui-agent-linux-arm64.sha256)
|
|
else
|
|
: "${PREV_TAG:?AGENT_CHANGED=0 requires PREV_TAG (the release to reuse agent assets from)}"
|
|
echo "== agent assets reused verbatim from $PREV_TAG (line stays $AGENT_VER) =="
|
|
for f in x-ui-agent-linux-amd64 x-ui-agent-linux-amd64.sha256 \
|
|
x-ui-agent-linux-arm64 x-ui-agent-linux-arm64.sha256; do
|
|
curl -fsSL -o "$OUT/$f" "${DL_BASE}${PREV_TAG}/${f}"
|
|
done
|
|
# Verify each reused binary against its shipped sidecar.
|
|
for a in amd64 arm64; do
|
|
want="$(awk '{print $1}' "$OUT/x-ui-agent-linux-$a.sha256")"
|
|
got="$(sha256sum "$OUT/x-ui-agent-linux-$a" | awk '{print $1}')"
|
|
[ "$want" = "$got" ] || { echo "FATAL: reused agent $a sha mismatch"; exit 1; }
|
|
done
|
|
fi
|
|
|
|
echo "== agent version marker =="
|
|
printf '%s\n' "$AGENT_VER" > "$OUT/agent-version.txt"
|
|
|
|
echo "== done =="
|
|
ls -la "$OUT"
|
|
echo "NOTE: no Windows exe is built — the Windows agent line is frozen"
|
|
echo "at A2.2.1 (V2.4.0 was its last release). See docs/release.md."
|