forked from v3io/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
257 lines (233 loc) · 8.72 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
GITHUB_BRANCH_DEFAULT := development
GITHUB_BRANCH := $(if $(GITHUB_BRANCH_OVERRIDE),$(GITHUB_BRANCH_OVERRIDE),$(GITHUB_BRANCH_DEFAULT))
HELM=helm
HELM_REPO_DEFAULT := https://v3io.github.io/helm-charts
HELM_REPO_ROOT := $(if $(HELM_REPO_OVERRIDE),$(HELM_REPO_OVERRIDE),$(HELM_REPO_DEFAULT))
WORKDIR := stable
HELM_REPO := $(HELM_REPO_ROOT)/$(WORKDIR)
CHART_NAME := $(if $(CHART_NAME),$(CHART_NAME),chart-name)
CHART_VERSION_OVERRIDE := $(if $(CHART_VERSION_OVERRIDE),$(CHART_VERSION_OVERRIDE),none)
#### Some examples:
# make print-versions
# make helm-publish - release all changes from development
# GITHUB_BRANCH_OVERRIDE=integ_2.8 make helm-publish - release all changes from integ_2.8
# GITHUB_BRANCH_OVERRIDE=integ_2.8 CHART_NAME=pipelines make helm-publish-stable-specific - release only pipelines from integ_2.8
.PHONY: stable
stable: WORKDIR = stable
stable: check-helm repo-helm update-req package-all index
@echo "Done"
.PHONY: stable-specific
stable-specific: WORKDIR = stable
stable-specific: check-helm repo-helm update-req-specific package-specific index
@echo "Done"
.PHONY: demo
demo: WORKDIR = demo
demo: check-helm repo-helm update-req package-all index
@echo "Done"
.PHONY: demo-specific
demo-specific: WORKDIR = demo
demo-specific: check-helm repo-helm update-req-specific package-specific index
@echo "Done"
.PHONY: incubator
incubator: WORKDIR = incubator
incubator: check-helm repo-helm update-req package-all index
@echo "Done"
.PHONY: incubator-specific
incubator-specific: WORKDIR = incubator
incubator-specific: check-helm repo-helm update-req-specific package-specific index
@echo "Done"
.PHONY: cleanup-tmp-workspace
cleanup-tmp-workspace:
@rm -rf /tmp/v3io-helm-charts*
@echo "Cleaned up /tmp/v3io-helm-charts"
.PHONY: helm-publish
helm-publish: check-helm cleanup-tmp-workspace
helm-publish:
@echo "Preparing to release a new index from $(GITHUB_BRANCH)"
@git clone [email protected]:v3io/helm-charts /tmp/v3io-helm-charts
@cd /tmp/v3io-helm-charts && \
git checkout $(GITHUB_BRANCH) && \
git checkout gh-pages && \
git merge $(GITHUB_BRANCH) --message "Merging $(GITHUB_BRANCH) into gh-pages" && \
REF_SHA=$$(git log $(GITHUB_BRANCH) -1 | head -1) && \
make stable && \
git add --force stable/*tgz && \
git add stable/* && \
git commit --message "Merging stable $$REF_SHA" && \
make demo && \
git add --force demo/*tgz && \
git add demo/* && \
git commit --message "Merging demo $$REF_SHA" && \
make incubator && \
git add --force incubator/*tgz && \
git add incubator/* && \
git commit --message "Merging incubator $$REF_SHA" && \
git push
@echo "New index released!"
helm-publish: cleanup-tmp-workspace
.PHONY: helm-publish-demo-specific
helm-publish-demo-specific: cleanup-tmp-workspace
helm-publish-demo-specific:
@echo "Preparing to release a new demo index for $(CHART_NAME) from $(GITHUB_BRANCH)"
@git clone [email protected]:v3io/helm-charts /tmp/v3io-helm-charts
@cd /tmp/v3io-helm-charts && \
git checkout $(GITHUB_BRANCH) && \
git checkout gh-pages && \
git merge $(GITHUB_BRANCH) --message "Merging $(GITHUB_BRANCH) into gh-pages" && \
REF_SHA=$$(git log $(GITHUB_BRANCH) -1 | head -1) && \
make demo-specific && \
git add --force demo/$(CHART_NAME)-*tgz && \
git add demo/$(CHART_NAME) && \
git add demo/index.yaml && \
git commit --message "Merging $$CHART_NAME from $$REF_SHA" && \
git push
@echo "New index released!"
helm-publish-demo-specific: cleanup-tmp-workspace
.PHONY: helm-publish-incubator-specific
helm-publish-incubator-specific: cleanup-tmp-workspace
helm-publish-incubator-specific:
@echo "Preparing to release a new incubator index for $(CHART_NAME) from $(GITHUB_BRANCH)"
@rm -rf /tmp/v3io-helm-charts
@git clone [email protected]:v3io/helm-charts /tmp/v3io-helm-charts
@cd /tmp/v3io-helm-charts && \
git checkout $(GITHUB_BRANCH) && \
git checkout gh-pages && \
git merge $(GITHUB_BRANCH) --message "Merging $(GITHUB_BRANCH) into gh-pages" && \
REF_SHA=$$(git log $(GITHUB_BRANCH) -1 | head -1) && \
make incubator-specific && \
git add --force incubator/$(CHART_NAME)-*tgz && \
git add incubator/$(CHART_NAME) && \
git add incubator/index.yaml && \
git commit --message "Merging $$CHART_NAME from $$REF_SHA" && \
git push
@echo "New index released!"
helm-publish-incubator-specific: cleanup-tmp-workspace
.PHONY: helm-publish-stable-specific
helm-publish-stable-specific: cleanup-tmp-workspace
helm-publish-stable-specific:
@echo "Preparing to release a new stable index for $(CHART_NAME) from $(GITHUB_BRANCH)"
@git clone [email protected]:v3io/helm-charts /tmp/v3io-helm-charts
@cp -r /tmp/v3io-helm-charts /tmp/v3io-helm-charts-2
@cd /tmp/v3io-helm-charts-2 && \
git checkout $(GITHUB_BRANCH) && \
REF_SHA=$$(git log $(GITHUB_BRANCH) -1 | head -1) && \
make stable-specific && \
cd /tmp/v3io-helm-charts && \
git checkout gh-pages && \
mv /tmp/v3io-helm-charts-2/stable/$(CHART_NAME)-*tgz /tmp/v3io-helm-charts/stable/ && \
make index && \
git add --force stable/$(CHART_NAME)-*tgz && \
git add stable/index.yaml && \
git commit --message "Merging $$CHART_NAME from $$REF_SHA" && \
git push
@echo "New index released!"
helm-publish-stable-specific: cleanup-tmp-workspace
.PHONY: print-versions
print-versions:
@cd $(WORKDIR) && for chart in $$(ls -d */); do \
CHART_VERSION=$$(grep version $$chart/Chart.yaml | cut -f2 -d:) ;\
echo "# $$chart -->$$CHART_VERSION" ;\
if [ -e "$$chart/requirements.yaml" ]; then \
echo "depends on:" ;\
echo "$$(grep -v alias $$chart/requirements.yaml | grep -A 1 name | grep -ve '^--')" ; \
fi \
done
.PHONY: update-req
update-req: check-helm
@echo "Updating all charts requirements"
@cd $(WORKDIR) && for chart in $$(ls); do \
if [ -e "$$chart/requirements.yaml" ]; then \
echo "Updating '$$chart' requirements" ; \
$(HELM) dependency build $$chart ; \
if [ "$$?" != "0" ]; then \
echo "Chart $$chart failed dependency build" ; \
exit 103 ; \
fi ; \
fi ; \
done
.PHONY: update-req-specific
update-req-specific: check-helm
@echo "Updating $(CHART_NAME) chart requirements"
@cd $(WORKDIR) && if [ -e "$(CHART_NAME)/requirements.yaml" ]; then \
$(HELM) dependency build $(CHART_NAME) ; \
if [ "$$?" != "0" ]; then \
echo "Chart $(CHART_NAME) failed dependency build" ; \
exit 103 ; \
fi ; \
fi
.PHONY: package-all
package-all: check-helm
@echo "Packing charts"
@cd $(WORKDIR) && for chart in $$(ls -d */); do \
$(HELM) lint $$chart ; \
if [ "$$?" != "0" ]; then \
echo "Chart $$chart failed lint" ; \
exit 101 ; \
fi ; \
$(HELM) package $$chart ; \
if [ "$$?" != "0" ]; then \
echo "Chart $$chart failed package" ; \
exit 102 ; \
fi ; \
done
.PHONY: package-specific
package-specific: check-helm
@echo "Packing chart"
@cd $(WORKDIR); \
if [ "$(CHART_VERSION_OVERRIDE)" != "none" ]; then \
cp $(CHART_NAME)/Chart.yaml $(CHART_NAME)/Chart.yaml.old; \
awk '{if ($$1=="version:") {$$2="$(CHART_VERSION_OVERRIDE)"; print $$0} else print $$0}' $(CHART_NAME)/Chart.yaml > $(CHART_NAME)/tmp; \
mv $(CHART_NAME)/tmp $(CHART_NAME)/Chart.yaml; \
fi ; \
$(HELM) lint $(CHART_NAME); \
if [ "$$?" != "0" ]; then \
echo "Chart $(CHART_NAME) failed lint" ; \
if [ "$(CHART_VERSION_OVERRIDE)" != "none" ]; then \
mv $(CHART_NAME)/Chart.yaml.old $(CHART_NAME)/Chart.yaml; \
fi ; \
exit 103 ; \
fi ; \
$(HELM) package $(CHART_NAME) && if [ "$$?" != "0" ]; then \
echo "Chart $(CHART_NAME) failed package" ; \
if [ "$(CHART_VERSION_OVERRIDE)" != "none" ]; then \
mv $(CHART_NAME)/Chart.yaml.old $(CHART_NAME)/Chart.yaml; \
fi ; \
exit 103 ; \
fi ; \
if [ "$(CHART_VERSION_OVERRIDE)" != "none" ]; then \
mv $(CHART_NAME)/Chart.yaml.old $(CHART_NAME)/Chart.yaml; \
fi ; \
.PHONY: index
index:
@echo "Generating index.yaml"
$(HELM) repo index --merge $(WORKDIR)/index.yaml --url $(HELM_REPO_ROOT)/$(WORKDIR) $(WORKDIR)
@if [ "$$?" != "0" ]; then \
echo "Failed repo index" ; \
exit 111 ; \
fi ; \
.PHONY: repo-helm
repo-helm: check-helm
$(info $(shell $(HELM) repo add v3io-$(WORKDIR) $(HELM_REPO)))
.PHONY: check-helm
check-helm:
@echo "Checking if helm command exists"
@$(HELM) help &> /dev/null
@if [ "$$?" != "0" ]; then \
echo "Missing helm command" ; \
exit 2 ; \
fi
@HELM_VERSION=$$($(HELM) version --short --client) && \
if [[ "$$HELM_VERSION" != *"v3"* ]]; then \
echo "Helm version must be 3" ; \
exit 2 ; \
fi
@echo "Helm command exists"
.PHONY: lint
lint:
@echo "Linting all charts"
./hack/scripts/lint.sh
.PHONY: repo-add
repo-add:
helm repo add stable https://charts.helm.sh/stable
helm repo add nuclio https://nuclio.github.io/nuclio/charts
helm repo add v3io-stable https://v3io.github.io/helm-charts/stable