-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
62 lines (51 loc) · 1.45 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
BIN_NAME=sdpctl
GOFMT_FILES?=$$(find . -name '*.go' | grep -v vendor)
GORELEASER_CROSS_VERSION=v1.20.0
DESTDIR :=
prefix := /usr/local
bindir := ${prefix}/bin
commit=$$(git rev-parse HEAD)
commitPath=github.com/appgate/sdpctl/cmd.commit=${commit}
date=$$(date --iso-8601)
CGO := 0
ifeq ($(shell uname),Darwin)
CGO = 1
endif
.PHONY: build
build:
CGO_ENABLED=$(CGO) go build -o build/$(BIN_NAME) -ldflags="-X '${commitPath}' -X 'github.com/appgate/sdpctl/pkg/factory.dockerRegistry=$(DOCKER_REGISTRY_URL)' -X 'github.com/appgate/sdpctl/cmd.buildDate=$(date)'"
.PHONY: deps
deps:
mkdir -p build
go run main.go completion bash > build/bash_completion
go run main.go generate man
snapshot: clean
@if [ ! -f ".release-env" ]; then \
touch .release-env;\
fi
docker run \
--rm \
--env-file .release-env \
-v $(PWD):/go/src/github.com/user/repo \
-w /go/src/github.com/user/repo \
goreleaser/goreleaser-cross:$(GORELEASER_CROSS_VERSION) \
--snapshot
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"
fmt:
gofmt -w $(GOFMT_FILES)
.PHONY: docs
docs:
go run main.go generate html
# Run go test twice, since -race don't catch all edge cases
test:
go test ./... -count 1 -timeout 30s
go test ./... -race -covermode=atomic -coverprofile=cover.out -timeout 60s
cover: test
go tool cover -func cover.out
clean:
rm -rf build dist cover.out
.PHONY: install
install: build
install -d ${DESTDIR}${bindir}
install -m755 build/$(BIN_NAME) ${DESTDIR}${bindir}/