-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
51 lines (40 loc) · 1.25 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
.PHONY: clean check build.local build.linux build.osx
BINARY ?= kube-nodes-downscaler
IMAGE ?= x0rg/kube-nodes-downscaler
VERSION ?= v0.0.5
TAG ?= $(VERSION)
GITHEAD = $(shell git rev-parse --short HEAD)
GITURL = $(shell git config --get remote.origin.url)
GITSTATUS = $(shell git status --porcelain || echo "no changes")
SOURCES = $(shell find . -name '*.go')
GOPKGS = $(shell go list ./... | grep -v /vendor/)
BUILD_FLAGS ?= -v
LDFLAGS ?= -w -s
default: build.local
clean:
rm -rf build
test:
go test -v -race -cover $(GOPKGS)
fmt:
go fmt $(GOPKGS)
check:
golint $(GOPKGS)
go vet -v $(GOPKGS)
tag:
if test "$(TAG)" = "" ; then \
echo "usage: make tag TAG=1.2.3"; \
exit 1; \
fi
git tag -a $(TAG) -m "$(TAG)"
git push origin $(TAG)
build.local: build/$(BINARY)
build.linux: build/linux/$(BINARY)
build.osx: build/osx/$(BINARY)
build/$(BINARY): $(SOURCES)
go build -o build/$(BINARY) $(BUILD_FLAGS) -ldflags "$(LDFLAGS)" .
build/linux/$(BINARY): $(SOURCES)
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/linux/$(BINARY) -ldflags "$(LDFLAGS)" .
build.docker:
docker build --rm --tag "$(IMAGE):$(VERSION)" .
build.push: build.docker
docker push "$(IMAGE):$(VERSION)"