Build, test, run, install and clean targets, with the version injected at link time. CI runs make check, build and test.
38 lines
768 B
Makefile
38 lines
768 B
Makefile
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
|
|
GOPATH := $(shell go env GOPATH)
|
|
LDFLAGS := "-X 'main.version=$(VERSION)'"
|
|
DIST_LDFLAGS := $(LDFLAGS)" -s -w"
|
|
|
|
export GOPRIVATE=coopcloud.tech
|
|
|
|
all: format check build test
|
|
|
|
run:
|
|
@go run -ldflags=$(LDFLAGS) .
|
|
|
|
install:
|
|
@go install -ldflags=$(LDFLAGS) .
|
|
|
|
build-dev:
|
|
@go build -v -ldflags=$(LDFLAGS) -o cctuip-dev .
|
|
|
|
build:
|
|
@go build -v -ldflags=$(DIST_LDFLAGS) -o cctuip .
|
|
|
|
clean:
|
|
@rm -f cctuip cctuip-dev
|
|
@rm -f '$(GOPATH)/bin/cctuip'
|
|
|
|
format:
|
|
@gofmt -s -w .
|
|
|
|
check:
|
|
@test -z $$(gofmt -s -l .) || \
|
|
(echo "gofmt: formatting issue - run 'make format' to resolve" && exit 1)
|
|
@go vet ./...
|
|
|
|
test:
|
|
@go test ./... -cover -v
|
|
|
|
loc:
|
|
@find . -name "*.go" | xargs wc -l
|