From 623dc62833b60beb4862b5740b105a1e2aaf32fa Mon Sep 17 00:00:00 2001 From: Shulhan Date: Mon, 3 Feb 2025 21:50:34 +0700 Subject: 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". --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index e05ef0d..dc024f6 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,12 @@ ## SPDX-FileCopyrightText: 2021 M. Shulhan ## 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 -- cgit v1.3