summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-07-27 03:27:51 +0700
committerShulhan <ms@kilabit.info>2022-07-27 03:27:51 +0700
commitedf46a7816b689288fbe1b57265cf3980517dbdd (patch)
tree1500c69bca69920a3c02a840c4e9f44ff0b05ac8
parent43f668c8818ac68223138d74c9a6f6f4a7007986 (diff)
downloadpakakeh.go-edf46a7816b689288fbe1b57265cf3980517dbdd.tar.xz
all: make the share.Version in the command to be dynamic
Instead of using only the last tagged version use the last tag plus latest commit hash. This changes require the Version and other constants that use it to be declared as variable.
-rw-r--r--Makefile6
-rw-r--r--lib/http/client.go2
-rw-r--r--share.go2
3 files changed, 7 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 5eebd355..4f2e391e 100644
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,7 @@ CPU_PROF:=cpu.prof
MEM_PROF:=mem.prof
CIIGO := ${GOBIN}/ciigo
+VERSION := $(shell git describe --tags)
.PHONY: all install lint build docs docs-serve clean distclean
.PHONY: test test.prof bench.lib.websocket coverbrowse
@@ -17,9 +18,12 @@ all: test lint build
install:
go install ./cmd/...
+build: BUILD_FLAGS=-ldflags "-s -w -X 'github.com/shuLhan/share.Version=$(VERSION)'"
+build: GOOS=linux
+build: GOARCH=amd64
build:
mkdir -p _bin/linux-amd64
- GOOS=linux GOARCH=amd64 go build -o _bin/linux-amd64/ ./cmd/...
+ go build $(BUILD_FLAGS) -o _bin/linux-amd64/ ./cmd/...
test:
CGO_ENABLED=1 go test -failfast -race -count=1 -coverprofile=$(COVER_OUT) ./...
diff --git a/lib/http/client.go b/lib/http/client.go
index 1357b995..99ef6ca1 100644
--- a/lib/http/client.go
+++ b/lib/http/client.go
@@ -28,7 +28,7 @@ import (
"github.com/shuLhan/share/lib/debug"
)
-const (
+var (
defUserAgent = "libhttp/" + share.Version +
" (github.com/shuLhan/share/lib/http; ms@kilabit.info)"
)
diff --git a/share.go b/share.go
index d5fce1aa..0cc1c75a 100644
--- a/share.go
+++ b/share.go
@@ -6,7 +6,7 @@
// language, and tools written in Go.
package share
-const (
+var (
// Version of this module.
Version = "0.39.0"
)