forked from cnabio/duffle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (76 loc) · 2.36 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
PROJECT := duffle
ORG := deislabs
DOCKER_REGISTRY ?= $(ORG)
BINDIR := $(CURDIR)/bin
GOFLAGS :=
LDFLAGS := -w -s
TESTFLAGS :=
INSTALL_DIR := /usr/local/bin
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
SHELL = cmd.exe
CHECK = where.exe
else
TARGET = $(PROJECT)
SHELL ?= bash
CHECK ?= which
endif
GIT_TAG := $(shell git describe --tags --always)
VERSION ?= ${GIT_TAG}
# Replace + with -, for Docker image tag compliance
IMAGE_TAG ?= $(subst +,-,$(VERSION))
LDFLAGS += -X github.com/$(ORG)/$(PROJECT)/pkg/version.Version=$(VERSION)
.PHONY: default
default: build
.PHONY: build
build:
go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(TARGET) github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: install
install:
install $(BINDIR)/$(TARGET) $(INSTALL_DIR)
CX_OSES = linux windows darwin
CX_ARCHS = amd64
.PHONY: build-release
build-release:
@for os in $(CX_OSES); do \
echo "building $$os"; \
for arch in $(CX_ARCHS); do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(PROJECT)-$$os-$$arch github.com/$(ORG)/$(PROJECT)/cmd/...; \
done; \
if [ $$os = 'windows' ]; then \
mv $(BINDIR)/$(PROJECT)-$$os-$$arch $(BINDIR)/$(PROJECT)-$$os-$$arch.exe; \
fi; \
done
.PHONY: debug
debug:
go build $(GOFLAGS) -o $(BINDIR)/$(TARGET) github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: build-docker-bin
build-docker-bin:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(GOFLAGS) -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(TARGET) github.com/$(ORG)/$(PROJECT)/cmd/...
.PHONY: docker-build
docker-build:
docker build -t $(DOCKER_REGISTRY)/$(PROJECT):$(IMAGE_TAG) .
.PHONY: docker-push
docker-push:
docker push $(DOCKER_REGISTRY)/$(PROJECT):$(IMAGE_TAG)
.PHONY: test
test:
go test $(TESTFLAGS) ./...
.PHONY: lint
lint:
golangci-lint run --config ./golangci.yml
HAS_DEP := $(shell $(CHECK) dep)
HAS_GOLANGCI := $(shell $(CHECK) golangci-lint)
.PHONY: build-drivers
build-drivers:
cp drivers/azure-vm/$(PROJECT)-azvm.sh bin/$(PROJECT)-azvm
cd drivers/azure-vm && pip3 install -r requirements.txt
.PHONY: bootstrap
bootstrap:
ifndef HAS_DEP
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
endif
ifndef HAS_GOLANGCI
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOPATH)/bin
endif
dep ensure -vendor-only -v