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'.
This commit is contained in:
sol_bot Bot committed 2026-11-28 14:55:38 +03:00
1 parent d19efd2dd2
commit 20021cb14f
2 files changed
+20 -7

No files matched your search

+6 -4
View File
@@ -1,4 +1,6 @@
VERSION= $(shell cat ./VERSION) VERSION= $(shell cat ./VERSION)
VERSION_STRING= v$(VERSION)/masyunis
LDFLAGS_VERSION= -X 'github.com/TecharoHQ/anubis.Version=$(VERSION_STRING)'
GO?= go GO?= go
NPM?= npm NPM?= npm
@@ -19,8 +21,8 @@ assets: deps
./xess/build.sh ./xess/build.sh
build: assets build: assets
$(GO) build -o ./var/anubis ./cmd/anubis $(GO) build -o ./var/anubis -ldflags "$(LDFLAGS_VERSION)" ./cmd/anubis
$(GO) build -o ./var/robots2policy ./cmd/robots2policy $(GO) build -o ./var/robots2policy -ldflags "$(LDFLAGS_VERSION)" ./cmd/robots2policy
@echo "Anubis is now built to ./var/anubis" @echo "Anubis is now built to ./var/anubis"
lint: assets lint: assets
@@ -28,8 +30,8 @@ lint: assets
$(GO) tool staticcheck ./... $(GO) tool staticcheck ./...
prebaked-build: prebaked-build:
$(GO) build -o ./var/anubis -ldflags "-X 'github.com/TecharoHQ/anubis.Version=$(VERSION)'" ./cmd/anubis $(GO) build -o ./var/anubis -ldflags "$(LDFLAGS_VERSION)" ./cmd/anubis
$(GO) build -o ./var/robots2policy -ldflags "-X 'github.com/TecharoHQ/anubis.Version=$(VERSION)'" ./cmd/robots2policy $(GO) build -o ./var/robots2policy -ldflags "$(LDFLAGS_VERSION)" ./cmd/robots2policy
test: assets test: assets
$(GO) test ./... $(GO) test ./...
+14 -3
View File
@@ -7,6 +7,12 @@ import (
) )
func init() { 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() bi, ok := debug.ReadBuildInfo()
if !ok { if !ok {
return return
@@ -14,14 +20,19 @@ func init() {
// XXX(Xe): many things in this repo assume that the development version // XXX(Xe): many things in this repo assume that the development version
// of anubis is `devel` and ReadBuildInfo returns `(devel)`. Shim the gap. // of anubis is `devel` and ReadBuildInfo returns `(devel)`. Shim the gap.
if bi.Main.Version != "(devel)" { if bi.Main.Version != "(devel)" && bi.Main.Version != "" {
Version = 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. // 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" var Version = "devel"
// CookieName is the name of the cookie that Anubis uses in order to validate // CookieName is the name of the cookie that Anubis uses in order to validate