From 20021cb14f4efdbdee63aeb2176faecaa98f4cb5 Mon Sep 17 00:00:00 2001 From: Lead <3+lead_bot@noreply.git.unvr.site> Date: Sat, 28 Nov 2026 14:55:38 +0300 Subject: [PATCH] Version: stamp v1.28.2/masyunis The Makefile build and prebaked-build targets now stamp Version=v$(VERSION)/masyunis via -ldflags. anubis.go keeps a link-time stamp instead of overwriting it with the VCS/module version from debug.ReadBuildInfo, and appends /masyunis when it does fall back to the module version. go run/go test still see 'devel'. --- Makefile | 10 ++++++---- anubis.go | 17 ++++++++++++++--- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 8006193..f4af28f 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ VERSION= $(shell cat ./VERSION) +VERSION_STRING= v$(VERSION)/masyunis +LDFLAGS_VERSION= -X 'github.com/TecharoHQ/anubis.Version=$(VERSION_STRING)' GO?= go NPM?= npm @@ -19,8 +21,8 @@ assets: deps ./xess/build.sh build: assets - $(GO) build -o ./var/anubis ./cmd/anubis - $(GO) build -o ./var/robots2policy ./cmd/robots2policy + $(GO) build -o ./var/anubis -ldflags "$(LDFLAGS_VERSION)" ./cmd/anubis + $(GO) build -o ./var/robots2policy -ldflags "$(LDFLAGS_VERSION)" ./cmd/robots2policy @echo "Anubis is now built to ./var/anubis" lint: assets @@ -28,8 +30,8 @@ lint: assets $(GO) tool staticcheck ./... prebaked-build: - $(GO) build -o ./var/anubis -ldflags "-X 'github.com/TecharoHQ/anubis.Version=$(VERSION)'" ./cmd/anubis - $(GO) build -o ./var/robots2policy -ldflags "-X 'github.com/TecharoHQ/anubis.Version=$(VERSION)'" ./cmd/robots2policy + $(GO) build -o ./var/anubis -ldflags "$(LDFLAGS_VERSION)" ./cmd/anubis + $(GO) build -o ./var/robots2policy -ldflags "$(LDFLAGS_VERSION)" ./cmd/robots2policy test: assets $(GO) test ./... diff --git a/anubis.go b/anubis.go index 00626f9..438c05c 100644 --- a/anubis.go +++ b/anubis.go @@ -7,6 +7,12 @@ import ( ) func init() { + // masyunis: a version stamped at link time (see the Makefile, which sets + // it to v$(VERSION)/masyunis) takes precedence over the module version. + if Version != "devel" { + return + } + bi, ok := debug.ReadBuildInfo() if !ok { return @@ -14,14 +20,19 @@ func init() { // XXX(Xe): many things in this repo assume that the development version // of anubis is `devel` and ReadBuildInfo returns `(devel)`. Shim the gap. - if bi.Main.Version != "(devel)" { - Version = bi.Main.Version + if bi.Main.Version != "(devel)" && bi.Main.Version != "" { + Version = bi.Main.Version + ForkSuffix } } +// ForkSuffix marks builds of the Masyunis fork in the displayed version. +const ForkSuffix = "/masyunis" + // Version is the current version of Anubis. // -// This is set from the Go module runtime version. +// This is set from the Go module runtime version, or at link time with +// -ldflags "-X 'github.com/TecharoHQ/anubis.Version=...'". It stays "devel" +// for go run / go test so development-only behaviour keeps working. var Version = "devel" // CookieName is the name of the cookie that Anubis uses in order to validate