diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4a927e1..8191462 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -19,6 +19,11 @@ builds: main: ./cmd/openfeature/ env: - CGO_ENABLED=0 + ldflags: + - -s -w + - -X main.version={{ .Version }} + - -X main.commit={{ .FullCommit }} + - -X main.date={{ .Date }} goos: - linux - windows diff --git a/Makefile b/Makefile index d455418..62d70c8 100644 --- a/Makefile +++ b/Makefile @@ -19,12 +19,18 @@ help: @echo " fmt - Format Go code" @echo " ci - Run all CI checks locally (fmt, lint, test, verify-generate)" +# Build variables +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") +COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown") +DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ") +LDFLAGS := -s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE) + .PHONY: build build: @echo "Building CLI binary..." @mkdir -p bin - @go build -o bin/openfeature ./cmd/openfeature - @echo "CLI binary built successfully at bin/openfeature" + @go build -ldflags "$(LDFLAGS)" -o bin/openfeature ./cmd/openfeature + @echo "CLI binary built successfully at bin/openfeature (version: $(VERSION))" .PHONY: install install: build