From 2195cfce131ee599c71d0c426a7eea70ed52345f Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 23 Oct 2024 16:01:36 +0200 Subject: Inject version with embed instead of build flags The build flags made the basic build and debug calls quite complex and bound this strictly to Git repositories which is a problem if the source code is passed around as tar archive. Embedding this via Go's embed package and a VERSION.txt file makes this way easier. A simple `go build` command is sufficient to build ceres. To make sure the version string is extended by a `-devel` marker and that this marker is removed before a release a RELEASE.md file was added as a checklist for releases. --- Makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index b9d5d51..0d8853e 100644 --- a/Makefile +++ b/Makefile @@ -2,16 +2,14 @@ TARGET_EXEC := ceres BUILD_DIR := ./build MODULE_NAME := xengineering.eu/ceres -VERSION := $(shell git describe --dirty --always) - all: $(BUILD_DIR)/$(TARGET_EXEC) $(BUILD_DIR)/$(TARGET_EXEC): - go build -ldflags "-X main.version=$(VERSION)" -o $@ $(MODULE_NAME) + go build -o $@ $(MODULE_NAME) .PHONY: debug debug: - go run -race -ldflags "-X main.version=$(VERSION)" $(MODULE_NAME) -e + go run -race $(MODULE_NAME) -e .PHONY: tests tests: -- cgit v1.2.3-70-g09d2