-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
80 lines (64 loc) · 1.79 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
NAME := k8s-pod-notifier
VERSION := v0.1.0
REVISION := $(shell git rev-parse --short HEAD)
SRCS := $(shell find . -name '*.go' -type f)
LDFLAGS := -ldflags="-s -w -X \"main.Version=$(VERSION)\" -X \"main.Revision=$(REVISION)\""
DIST_DIRS := find * -type d -exec
DOCKER_REPOSITORY := quay.io
DOCKER_IMAGE_NAME := $(DOCKER_REPOSITORY)/dtan4/k8s-pod-notifier
DOCKER_IMAGE_TAG ?= latest
DOCKER_IMAGE := $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)
.DEFAULT_GOAL := bin/$(NAME)
bin/$(NAME): $(SRCS)
go build $(LDFLAGS) -o bin/$(NAME)
.PHONY: ci-docker-release
ci-docker-release: docker-build
@docker login -u="$(DOCKER_USERNAME)" -p="$(DOCKER_PASSWORD)" $(DOCKER_REPOSITORY)
docker push $(DOCKER_IMAGE)
.PHONY: clean
clean:
rm -rf bin/*
rm -rf vendor/*
.PHONY: cross-build
cross-build:
for os in darwin linux windows; do \
for arch in amd64 386; do \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build $(LDFLAGS) -o dist/$$os-$$arch/$(NAME); \
done; \
done
.PHONY: deps
deps: glide
glide install
.PHONY: dist
dist:
cd dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \
cd ..
.PHONY: docker-build
docker-build:
ifeq ($(findstring ELF 64-bit LSB,$(shell file bin/$(NAME) 2> /dev/null)),)
@echo "bin/$(NAME) is not a binary of Linux 64bit binary."
@exit 1
endif
docker build -t $(DOCKER_IMAGE) .
.PHONY: glide
glide:
ifeq ($(shell command -v glide 2> /dev/null),)
curl https://glide.sh/get | sh
endif
.PHONY: install
install:
go install $(LDFLAGS)
.PHONY: release
release:
git tag $(VERSION)
git push origin $(VERSION)
.PHONY: test
test:
go test -cover -v `glide novendor`
.PHONY: update-deps
update-deps: glide
glide update