This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
111 lines (85 loc) · 2.71 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GODEP=dep
PREFIX=.
ARTIFACT_DIR ?= .
REGISTRY=quay.io/rgolangh
VERSION?=$(shell git describe --tags --always --match "v[0-9]*" | awk -F'-' '{print substr($$1,2) }')
RELEASE?=$(shell git describe --tags --always --match "v[0-9]*" | awk -F'-' '{if ($$2 != "") {print $$2 "." $$3} else {print 1}}')
VERSION_RELEASE=$(VERSION)$(if $(RELEASE),-$(RELEASE))
COMMIT=$(shell git rev-parse HEAD)
BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
COMMON_ENV=CGO_ENABLED=0 GOOS=linux GOARCH=amd64
COMMON_GO_BUILD_FLAGS=-ldflags '-extldflags "-static"'
TARBALL=ovirt-openshift-extensions-$(VERSION_RELEASE).tar.gz
PUSH_LATEST=1
all: clean deps build test build-containers
binaries = \
ovirt-flexvolume-driver \
ovirt-volume-provisioner \
ovirt-cloud-provider
containers = \
$(binaries) \
ovirt-openshift-installer
$(binaries): test internal
go vet ./cmd/$@ && \
$(COMMON_ENV) $(GOBUILD) \
$(COMMON_GO_BUILD_FLAGS) \
-o $(PREFIX)/$@ \
-v cmd/$@/*.go
internal:
go vet ./internal
container-%: DIR=.
container-%: DOCKERFILE=deployment/$*/container/Dockerfile
container-ovirt-openshift-installer: DIR=automation/ci
container-ovirt-openshift-installer: DOCKERFILE=$(DIR)/Dockerfile
container-%: tarball
docker build \
-t $(REGISTRY)/$*:$(VERSION_RELEASE) \
-t $(REGISTRY)/$*:latest \
--build-arg version=$(VERSION) \
--build-arg release=$(RELEASE) \
-f $(DOCKERFILE) \
$(DIR)
container-push-%:
@docker login -u rgolangh+ovirtci -p ${QUAY_API_KEY} quay.io
docker push $(REGISTRY)/$*:$(VERSION_RELEASE)
ifneq ($(PUSH_LATEST),0)
docker push $(REGISTRY)/$*:latest
endif
echo "$(REGISTRY)/$*:$(VERSION_RELEASE)" >> containers-artifacts.list
build: $(binaries)
build-containers: $(addprefix container-, $(containers))
push-containers: $(addprefix container-push-, $(containers))
test:
$(GOTEST) -v ./... -coverprofile=coverage.out
go tool cover -html=coverage.out -o /tmp/coverage.html
clean:
$(GOCLEAN)
git clean -dfx -e .idea*
deps:
dep ensure --update
tarball: $(TARBALL)
$(TARBALL):
/bin/git archive --format=tar.gz HEAD > $(TARBALL)
apb_build:
$(MAKE) -C deployment/ovirt-flexvolume-driver-apb/ \
REGISTRY=$(REGISTRY) \
VERSION=$(VERSION) \
RELEASE=$(RELEASE) \
VERSION_RELEASE=$(VERSION_RELEASE) \
apb_build
apb_push:
$(MAKE) -C deployment/ovirt-flexvolume-driver-apb/ apb_push REGISTRY=$(REGISTRY)
apb_docker_push:
$(MAKE) -C deployment/ovirt-flexvolume-driver-apb/ \
REGISTRY=$(REGISTRY) \
VERSION=$(VERSION) \
RELEASE=$(RELEASE) \
VERSION_RELEASE=$(VERSION_RELEASE) \
docker_push
.PHONY: all internal tarball test build build-containers push-containers apb_build apb_docker_push apb_push