summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--svc/conf.go4
-rw-r--r--svc/help.go2
-rw-r--r--svc/init.go4
-rw-r--r--svc/init_test.go5
-rw-r--r--svc/svc.go2
6 files changed, 10 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 598ff00..2151717 100644
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,9 @@
 PREFIX?=/usr/local
 _INSTDIR=$(PREFIX)
 BINDIR?=$(_INSTDIR)/getwtxt
+VERSION?=$(shell git tag | grep ^v | sort -V | tail -n 1)
 GOFLAGS?=-tags netgo \
-				 -ldflags '-extldflags "-static"' \
+				 -ldflags '-X github.com/getwtxt/getwtxt/svc.Vers=${VERSION} -extldflags "-static"' \
 				 -buildmode pie
 
 getwtxt: getwtxt.go go.mod go.sum
diff --git a/svc/conf.go b/svc/conf.go
index 5f4233b..d85bbee 100644
--- a/svc/conf.go
+++ b/svc/conf.go
@@ -157,9 +157,9 @@ func initConfig() {
 
 	confObj.LastCache = time.Now()
 	confObj.LastPush = time.Now()
-	confObj.Version = getwtxt
+	confObj.Version = Vers
 
-	confObj.Instance.Vers = getwtxt
+	confObj.Instance.Vers = Vers
 	confObj.Instance.Name = viper.GetString("Instance.SiteName")
 	confObj.Instance.URL = viper.GetString("Instance.URL")
 	confObj.Instance.Owner = viper.GetString("Instance.OwnerName")
diff --git a/svc/help.go b/svc/help.go
index 9566f93..09faadb 100644
--- a/svc/help.go
+++ b/svc/help.go
@@ -11,7 +11,7 @@ func titleScreen() {
            | (_| |  __/ |_ \ V  V /| |_ >  <| |_
             \__, |\___|\__| \_/\_/  \__/_/\_\\__|
             |___/
-                       version ` + getwtxt + `
+                       version ` + Vers + `
                  github.com/getwtxt/getwtxt
                           GPL  v3  
 
diff --git a/svc/init.go b/svc/init.go
index e9c64af..6af7866 100644
--- a/svc/init.go
+++ b/svc/init.go
@@ -12,9 +12,9 @@ import (
 	"github.com/spf13/pflag"
 )
 
-const getwtxt = "0.3.0"
-
 var (
+	// Vers contains the version number set at build time
+	Vers         string
 	flagVersion  *bool   = pflag.BoolP("version", "v", false, "Display version information, then exit.")
 	flagHelp     *bool   = pflag.BoolP("help", "h", false, "Display the quick-help screen.")
 	flagMan      *bool   = pflag.BoolP("manual", "m", false, "Display the configuration manual.")
diff --git a/svc/init_test.go b/svc/init_test.go
index 385db0e..b2fcd9a 100644
--- a/svc/init_test.go
+++ b/svc/init_test.go
@@ -82,9 +82,9 @@ func testConfig() {
 
 	confObj.LastCache = time.Now()
 	confObj.LastPush = time.Now()
-	confObj.Version = getwtxt
+	confObj.Version = Vers
 
-	confObj.Instance.Vers = getwtxt
+	confObj.Instance.Vers = Vers
 	confObj.Instance.Name = viper.GetString("Instance.SiteName")
 	confObj.Instance.URL = viper.GetString("Instance.URL")
 	confObj.Instance.Owner = viper.GetString("Instance.OwnerName")
@@ -93,7 +93,6 @@ func testConfig() {
 }
 
 func mockRegistry() {
-
 	statuses, _, _ := registry.GetTwtxt("https://gbmor.dev/twtxt.txt")
 	parsed, _ := registry.ParseUserTwtxt(statuses, "gbmor", "https://gbmor.dev/twtxt.txt")
 	_ = twtxtCache.AddUser("gbmor", "https://gbmor.dev/twtxt.txt", "1", net.ParseIP("127.0.0.1"), parsed)
diff --git a/svc/svc.go b/svc/svc.go
index ae5f7e9..4d781eb 100644
--- a/svc/svc.go
+++ b/svc/svc.go
@@ -112,7 +112,7 @@ func Start() {
 	}
 
 	log.Printf("\nListening on %v\n", portnum)
-	log.Printf("\n:: getwtxt %v Started :: %v ::\n\n", getwtxt, time.Now().Format(time.RFC3339))
+	log.Printf("\n:: getwtxt %v Started :: %v ::\n\n", Vers, time.Now().Format(time.RFC3339))
 	errLog("", server.ListenAndServe())
 
 	closeLog <- true