-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·61 lines (53 loc) · 1.47 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
HAS_GOLINT := $(shell command -v golint;)
VERSION :=
COMMIT :=
DIST := $(CURDIR)/_dist
BUILD := $(CURDIR)/_build
LDFLAGS := "-X main.version=${VERSION} -X main.commit=${COMMIT}"
BINARY := dockerctl
MAIN := ./cmd/dockerctl
.PHONY: install
install: bootstrap test build
.PHONY: test
test: golint
go test ./... -v
.PHONY: gofmt
gofmt:
gofmt -s -w .
.PHONY: golint
golint: gofmt
ifndef HAS_GOLINT
go get -u golang.org/x/lint/golint
endif
golint -set_exit_status ./cmd/...
golint -set_exit_status ./pkg/...
.PHONY: build
build: clean bootstrap
mkdir -p $(BUILD)
go build -o $(BUILD)/$(BINARY) $(MAIN)
.PHONY: dist
dist:
ifeq ($(strip $(VERSION)),)
$(error VERSION is not set)
endif
ifeq ($(strip $(COMMIT)),)
$(error COMMIT is not set)
endif
go get -u github.com/inconshreveable/mousetrap
mkdir -p $(BUILD)
mkdir -p $(DIST)
GOOS=linux GOARCH=amd64 go build -o $(BUILD)/$(BINARY) -ldflags $(LDFLAGS) -a -tags netgo $(MAIN)
tar -C $(BUILD) -zcvf $(DIST)/$(BINARY)-linux-$(VERSION).tgz $(BINARY)
GOOS=darwin GOARCH=amd64 go build -o $(BUILD)/$(BINARY) -ldflags $(LDFLAGS) -a -tags netgo $(MAIN)
tar -C $(BUILD) -zcvf $(DIST)/$(BINARY)-darwin-$(VERSION).tgz $(BINARY)
GOOS=windows GOARCH=amd64 go build -o $(BUILD)/$(BINARY).exe -ldflags $(LDFLAGS) -a -tags netgo $(MAIN)
tar -C $(BUILD) -llzcvf $(DIST)/$(BINARY)-windows-$(VERSION).tgz $(BINARY).exe
.PHONY: bootstrap
bootstrap:
ifeq (,$(wildcard ./go.mod))
go mod init dockerctl
endif
go mod download
.PHONY: clean
clean:
rm -rf _*