- Update Makefile to inject VERSION and GIT_COMMIT at build time - Change Version from const to var to allow ldflags injection - Add build target to create binary with proper version info
24 lines
499 B
Makefile
24 lines
499 B
Makefile
VERSION := 1.0.0
|
|
GIT_COMMIT := $(shell git rev-parse HEAD)
|
|
LDFLAGS := -X 'git.eeqj.de/sneak/smartconfig.Version=$(VERSION)' -X 'git.eeqj.de/sneak/smartconfig.GitCommit=$(GIT_COMMIT)'
|
|
|
|
.PHONY: test lint check-fmt fmt build
|
|
|
|
test: lint check-fmt
|
|
go test -v ./...
|
|
|
|
lint:
|
|
golangci-lint run
|
|
|
|
check-fmt:
|
|
@if [ -n "$$(gofmt -l .)" ]; then \
|
|
echo "Go code is not formatted:"; \
|
|
gofmt -l .; \
|
|
exit 1; \
|
|
fi
|
|
|
|
fmt:
|
|
go fmt ./...
|
|
|
|
build:
|
|
go build -ldflags "$(LDFLAGS)" -o smartconfig ./cmd/smartconfig
|