forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
188 lines (156 loc) · 5.41 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
PACKAGE=github.com/argoproj/argo
CURRENT_DIR=$(shell pwd)
DIST_DIR=${CURRENT_DIR}/dist
ARGO_CLI_NAME=argo
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
GIT_TREE_STATE=$(shell if [ -z "`git status --porcelain`" ]; then echo "clean" ; else echo "dirty"; fi)
BUILDER_IMAGE=argo-builder
# NOTE: the volume mount of ${DIST_DIR}/pkg below is optional and serves only
# to speed up subsequent builds by caching ${GOPATH}/pkg between builds.
BUILDER_CMD=docker run --rm \
-v ${CURRENT_DIR}:/root/go/src/${PACKAGE} \
-v ${DIST_DIR}/pkg:/root/go/pkg \
-w /root/go/src/${PACKAGE} ${BUILDER_IMAGE}
override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
-X ${PACKAGE}.gitCommit=${GIT_COMMIT} \
-X ${PACKAGE}.gitTreeState=${GIT_TREE_STATE}
# docker image publishing options
DOCKER_PUSH=false
IMAGE_TAG=latest
ifneq (${GIT_TAG},)
IMAGE_TAG=${GIT_TAG}
override LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
endif
ifneq (${IMAGE_NAMESPACE},)
override LDFLAGS += -X ${PACKAGE}/cmd/argo/commands.imageNamespace=${IMAGE_NAMESPACE}
endif
ifneq (${IMAGE_TAG},)
override LDFLAGS += -X ${PACKAGE}/cmd/argo/commands.imageTag=${IMAGE_TAG}
endif
ifeq (${DOCKER_PUSH},true)
ifndef IMAGE_NAMESPACE
$(error IMAGE_NAMESPACE must be set to push images (e.g. IMAGE_NAMESPACE=argoproj))
endif
endif
ifdef IMAGE_NAMESPACE
IMAGE_PREFIX=${IMAGE_NAMESPACE}/
endif
# Build the project
.PHONY: all
all: cli cli-image controller-image executor-image
.PHONY: builder
builder:
docker build -t ${BUILDER_IMAGE} -f Dockerfile-builder .
.PHONY: cli
cli:
CGO_ENABLED=0 go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/${ARGO_CLI_NAME} ./cmd/argo
.PHONY: cli-linux-amd64
cli-linux-amd64: builder
${BUILDER_CMD} make cli \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
IMAGE_TAG=$(IMAGE_TAG) \
IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) \
LDFLAGS='-extldflags "-static"' \
ARGO_CLI_NAME=argo-linux-amd64
.PHONY: cli-linux-ppc64le
cli-linux-ppc64le: builder
${BUILDER_CMD} make cli \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=ppc64le \
IMAGE_TAG=$(IMAGE_TAG) \
IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) \
LDFLAGS='-extldflags "-static"' \
ARGO_CLI_NAME=argo-linux-ppc64le
.PHONY: cli-linux-s390x
cli-linux-s390x: builder
${BUILDER_CMD} make cli \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=s390x \
IMAGE_TAG=$(IMAGE_TAG) \
IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) \
LDFLAGS='-extldflags "-static"' \
ARGO_CLI_NAME=argo-linux-s390x
.PHONY: cli-linux
cli-linux: cli-linux-amd64 cli-linux-ppc64le cli-linux-s390x
.PHONY: cli-darwin
cli-darwin: builder
${BUILDER_CMD} make cli \
GOOS=darwin \
IMAGE_TAG=$(IMAGE_TAG) \
IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) \
ARGO_CLI_NAME=argo-darwin-amd64
.PHONY: cli-windows
cli-windows: builder
${BUILDER_CMD} make cli \
GOARCH=amd64 \
GOOS=windows \
IMAGE_TAG=$(IMAGE_TAG) \
IMAGE_NAMESPACE=$(IMAGE_NAMESPACE) \
LDFLAGS='-extldflags "-static"' \
ARGO_CLI_NAME=argo-windows-amd64
.PHONY: controller
controller:
go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/workflow-controller ./cmd/workflow-controller
.PHONY: cli-image
cli-image: cli-linux
docker build -t $(IMAGE_PREFIX)argocli:$(IMAGE_TAG) -f Dockerfile-cli .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argocli:$(IMAGE_TAG) ; fi
.PHONY: controller-linux
controller-linux: builder
${BUILDER_CMD} make controller
.PHONY: controller-image
controller-image: controller-linux
docker build -t $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) -f Dockerfile-workflow-controller .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)workflow-controller:$(IMAGE_TAG) ; fi
.PHONY: executor
executor:
go build -v -i -ldflags '${LDFLAGS}' -o ${DIST_DIR}/argoexec ./cmd/argoexec
.PHONY: executor-linux
executor-linux: builder
${BUILDER_CMD} make executor
.PHONY: executor-image
executor-image: executor-linux
docker build -t $(IMAGE_PREFIX)argoexec:$(IMAGE_TAG) -f Dockerfile-argoexec .
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argoexec:$(IMAGE_TAG) ; fi
.PHONY: lint
lint:
gometalinter --config gometalinter.json ./...
.PHONY: test
test:
go test ./...
.PHONY: update-codegen
update-codegen:
./hack/update-codegen.sh
./hack/update-openapigen.sh
go run ./hack/gen-openapi-spec/main.go ${VERSION} > ${CURRENT_DIR}/api/openapi-spec/swagger.json
.PHONY: verify-codegen
verify-codegen:
./hack/verify-codegen.sh
./hack/update-openapigen.sh --verify-only
mkdir -p ${CURRENT_DIR}/dist
go run ./hack/gen-openapi-spec/main.go ${VERSION} > ${CURRENT_DIR}/dist/swagger.json
diff ${CURRENT_DIR}/dist/swagger.json ${CURRENT_DIR}/api/openapi-spec/swagger.json
.PHONY: update-manifests
update-manifests:
./hack/update-manifests.sh
.PHONY: clean
clean:
-rm -rf ${CURRENT_DIR}/dist
.PHONY: precheckin
precheckin: test lint verify-codegen
.PHONY: release-precheck
release-precheck: precheckin
@if [ "$(GIT_TREE_STATE)" != "clean" ]; then echo 'git tree state is $(GIT_TREE_STATE)' ; exit 1; fi
@if [ -z "$(GIT_TAG)" ]; then echo 'commit must be tagged to perform release' ; exit 1; fi
@if [ "$(GIT_TAG)" != "v$(VERSION)" ]; then echo 'git tag ($(GIT_TAG)) does not match VERSION (v$(VERSION))'; exit 1; fi
.PHONY: release
release: release-precheck controller-image cli-darwin cli-linux cli-windows executor-image cli-image