diff options
| author | Shulhan <ms@kilabit.info> | 2025-02-03 21:50:34 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-02-03 21:50:34 +0700 |
| commit | 623dc62833b60beb4862b5740b105a1e2aaf32fa (patch) | |
| tree | 97207255e101b836d6def9e85a9acc601c90f72e | |
| parent | 1caeb5a45b1e1c1e0d21968cc54e9e55745b8a2b (diff) | |
| download | gotp-623dc62833b60beb4862b5740b105a1e2aaf32fa.tar.xz | |
all: set the Version using git describe and -ldflags
While at it, refactor the string output when printing the version to
print string "version" instead of only "v".
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | cmd/gotp/main.go | 2 |
2 files changed, 6 insertions, 2 deletions
@@ -1,9 +1,12 @@ ## SPDX-FileCopyrightText: 2021 M. Shulhan <ms@kilabit.info> ## SPDX-License-Identifier: GPL-3.0-or-later +VERSION := $(shell git describe --tags) + .PHONY: all all: test lint build +.PHONY: test test: CGO_ENABLED=1 go test -race -failfast -coverprofile=cover.out ./... go tool cover -html=cover.out -o cover.html @@ -14,9 +17,10 @@ lint: go vet ./... .PHONY: build +build: BUILD_FLAGS=-ldflags "-s -w -X 'git.sr.ht/~shulhan/gotp.Version=$(VERSION)'" build: mkdir -p _sys/usr/bin/ - go build -o _sys/usr/bin/ ./cmd/... + go build $(BUILD_FLAGS) -o _sys/usr/bin/ ./cmd/... .PHONY: install install: build diff --git a/cmd/gotp/main.go b/cmd/gotp/main.go index 1ae7587..097c371 100644 --- a/cmd/gotp/main.go +++ b/cmd/gotp/main.go @@ -108,7 +108,7 @@ func main() { } case cmdVersion: - fmt.Println(`gotp v`, gotp.Version) + fmt.Println(`gotp version`, gotp.Version) return default: |
