From 7cb9da85694e60afaeef1f46bd49fd7105af8b6d Mon Sep 17 00:00:00 2001 From: iRedTea Date: Tue, 13 Oct 2026 14:50:49 +0300 Subject: [PATCH] chore: take the version from VERSION.txt only (0.0.3) VERSION.txt is embedded into the server and the agent, so a plain go build reports the real version and build.sh no longer injects it. --- VERSION.txt | 2 +- build.sh | 7 +++---- internal/agent/client.go | 6 +++--- internal/server/config.go | 8 +++++--- version.go | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 11 deletions(-) create mode 100644 version.go diff --git a/VERSION.txt b/VERSION.txt index 4e379d2..bcab45a 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -0.0.2 +0.0.3 diff --git a/build.sh b/build.sh index 5841025..09bf69b 100755 --- a/build.sh +++ b/build.sh @@ -5,10 +5,9 @@ set -eu cd "$(dirname "$0")" -VERSION="${VERSION:-$(cat VERSION.txt 2>/dev/null || echo 0.0.0)}" -PKG="github.com/x-grk/longpolling-remote-access" -LDFLAGS="-s -w -X $PKG/internal/server.Version=$VERSION -X $PKG/internal/agent.Version=$VERSION" -echo ">> version $VERSION" +# The version comes from VERSION.txt, which is embedded into every binary. +LDFLAGS="-s -w" +echo ">> version $(cat VERSION.txt)" mkdir -p dist bin diff --git a/internal/agent/client.go b/internal/agent/client.go index 894adec..68e9eb0 100644 --- a/internal/agent/client.go +++ b/internal/agent/client.go @@ -18,12 +18,12 @@ import ( "runtime" "time" + lpra "github.com/x-grk/longpolling-remote-access" "github.com/x-grk/longpolling-remote-access/internal/proto" ) -// Version is the agent build version, injected at compile time via -ldflags -// (-X .../internal/agent.Version=...). -var Version = "dev" +// Version is the agent build version (see VERSION.txt). +var Version = lpra.Version // Config is the agent's runtime configuration (from env / config.env). type Config struct { diff --git a/internal/server/config.go b/internal/server/config.go index 5cacfeb..5753e90 100644 --- a/internal/server/config.go +++ b/internal/server/config.go @@ -3,6 +3,8 @@ package server import ( "crypto/rand" "encoding/hex" + + lpra "github.com/x-grk/longpolling-remote-access" ) // Config keys stored in the config table. @@ -18,9 +20,9 @@ const ( // the rendered install.sh and can be changed from the settings page. const DefaultHostAddress = "https://REDACTED:8445" -// Version is the server build version, injected at compile time via -ldflags -// (-X .../internal/server.Version=...). It is the newest version agents update to. -var Version = "dev" +// Version is the server build version (see VERSION.txt). It is the newest +// version agents update to. +var Version = lpra.Version // ensureDefaults seeds the host address and a random enroll secret on first boot. func (db *DB) ensureDefaults() error { diff --git a/version.go b/version.go new file mode 100644 index 0000000..0848cf8 --- /dev/null +++ b/version.go @@ -0,0 +1,14 @@ +// Package lpra holds what the server and the agent share at build time. +package lpra + +import ( + _ "embed" + "strings" +) + +//go:embed VERSION.txt +var versionFile string + +// Version is the release version of every binary in this module. VERSION.txt +// is the only place it is defined. +var Version = strings.TrimSpace(versionFile)