aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile15
1 files changed, 11 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index aeba359..5ac057f 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,12 @@ BINARY_NAME=nectar
BUILD_PATH=bin/$(BINARY_NAME)
MAIN_PATH=$(BINARY_NAME)/main.go
+VERSION ?= $(shell git describe --tags 2>/dev/null || echo "dev")
+BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
+
+# Build flags for setting version and build date
+LDFLAGS := -ldflags "-X nectar/build.Version=$(VERSION) -X nectar/build.Date=$(BUILD_DATE)"
+
.PHONY: setup clean build run dev all
setup:
@@ -15,8 +21,9 @@ clean:
@echo "Cleanup complete."
build:
- @echo "Building..."
- @go build -o $(BUILD_PATH) $(MAIN_PATH) || true
+ @echo "Building version $(VERSION) at $(BUILD_DATE)..."
+ @mkdir -p bin
+ @go build $(LDFLAGS) -o $(BUILD_PATH) $(MAIN_PATH) || true
@echo "Build complete."
run:
@@ -25,8 +32,8 @@ run:
@$(BUILD_PATH) || true
dev:
- @echo "Running in development mode..."
- @go run $(MAIN_PATH) || true
+ @echo "Running in development mode with version $(VERSION)..."
+ @go run $(LDFLAGS) $(MAIN_PATH) || true
all: setup clean build run