22 lines
621 B
Makefile
22 lines
621 B
Makefile
BIN_PATH:=./bin
|
|
CMD_PATH:=./cmd/server/main.go
|
|
|
|
LAST_COMMIT:=$(shell git rev-list --abbrev-commit --all --max-count=1)
|
|
TAG:=$(shell git describe --abbrev=0 --tags ${LAST_COMMIT} 2>/dev/null || true)
|
|
VERSION:=$(or $(TAG:v%=%),0.0.0)-$(LAST_COMMIT)
|
|
|
|
LDFLAGS=-extldflags=-static -w -s -w -s -X main.version=${VERSION}
|
|
|
|
.PHONY: build test lint
|
|
all: lint test build
|
|
|
|
build:
|
|
CGO_ENABLED=0 go build -ldflags='${LDFLAGS}' -o ${BIN_PATH}/service ./cmd/server/main.go
|
|
|
|
test:
|
|
go test -v -race ./...
|
|
|
|
lint:
|
|
@which golangci-lint || go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
|
|
golangci-lint run -j4 ./...
|