forked from pravega/zookeeper-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (74 loc) · 3.55 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
# Copyright (c) 2018 Dell Inc., or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
SHELL=/bin/bash -o pipefail
PROJECT_NAME=zookeeper-operator
EXPORTER_NAME=zookeeper-exporter
APP_NAME=zookeeper
REPO=pravega/$(PROJECT_NAME)
APP_REPO=pravega/$(APP_NAME)
ALTREPO=emccorp/$(PROJECT_NAME)
APP_ALTREPO=emccorp/$(APP_NAME)
VERSION=$(shell git describe --always --tags --dirty | sed "s/\(.*\)-g`git rev-parse --short HEAD`/\1/")
GIT_SHA=$(shell git rev-parse --short HEAD)
.PHONY: all build check clean test
all: dep check build
dep:
dep ensure -v
build: test build-go build-image
build-go:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-linux-amd64 cmd/manager/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-linux-amd64 cmd/exporter/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-darwin-amd64 cmd/manager/main.go
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-darwin-amd64 cmd/exporter/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(PROJECT_NAME)-windows-amd64.exe cmd/manager/main.go
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build \
-ldflags "-X github.com/$(REPO)/pkg/version.Version=$(VERSION) -X github.com/$(REPO)/pkg/version.GitSHA=$(GIT_SHA)" \
-o bin/$(EXPORTER_NAME)-windows-amd64.exe cmd/exporter/main.go
build-image:
docker build --build-arg VERSION=$(VERSION) --build-arg GIT_SHA=$(GIT_SHA) -t $(REPO):$(VERSION) .
docker tag $(REPO):$(VERSION) $(REPO):latest
build-zk-image:
docker build --build-arg VERSION=$(VERSION) --build-arg GIT_SHA=$(GIT_SHA) -t $(APP_REPO):$(VERSION) ./docker
docker tag $(APP_REPO):$(VERSION) $(APP_REPO):latest
build-zk-image-swarm:
docker build --build-arg VERSION=$(VERSION)-swarm --build-arg GIT_SHA=$(GIT_SHA) -f ./docker/Dockerfile-swarm -t $(APP_REPO):$(VERSION)-swarm ./docker
test:
go test $$(go list ./... | grep -v /vendor/) -race -coverprofile=coverage.txt -covermode=atomic
login:
@docker login -u "$(DOCKER_USER)" -p "$(DOCKER_PASS)"
push: build-image build-zk-image build-zk-image-swarm login
docker push $(REPO):$(VERSION)
docker push $(REPO):latest
docker push $(APP_REPO):$(VERSION)
docker push $(APP_REPO):latest
docker push $(APP_REPO):$(VERSION)-swarm
docker tag $(REPO):$(VERSION) $(ALTREPO):$(VERSION)
docker tag $(REPO):$(VERSION) $(ALTREPO):latest
docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):$(VERSION)
docker tag $(APP_REPO):$(VERSION) $(APP_ALTREPO):latest
docker push $(ALTREPO):$(VERSION)
docker push $(ALTREPO):latest
docker push $(APP_ALTREPO):$(VERSION)
docker push $(APP_ALTREPO):latest
clean:
rm -f bin/$(PROJECT_NAME)
check: check-format check-license
check-format:
./scripts/check_format.sh
check-license:
./scripts/check_license.sh