-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (76 loc) · 2.24 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
SHELL := /bin/bash
REDIS_CHART_VERSION ?= 4.2.7
export REDIS_CHART_VERSION
# Relative path to local chart bucket mirror
CHART_DIRECTORY ?= ../raywalker-helm-charts
# Remote chart bucket GCS bucket
CHART_BUCKET ?= gs://raywalker-helm-charts
CHART_URL ?= https://raywalker-helm-charts.storage.googleapis.com
# Name of current chart
CHART_NAME := $(shell basename "$(PWD)")
# Sed match for replacing build tags with machine-readable characters
SED_MATCH := [^a-zA-Z0-9._-]
# If BUILD_TAG is not set
ifeq ($(strip $(BUILD_TAG)),)
ifeq ($(CIRCLECI),true)
# Configure build variables based on CircleCI environment vars
BUILD_TAG ?= $(shell sed 's/$(SED_MATCH)/-/g' <<< "$(CIRCLE_TAG)")
else
# Not in CircleCI environment, try to set sane defaults
BUILD_TAG ?= $(shell git tag -l --points-at HEAD | tail -n1 | sed 's/$(SED_MATCH)/-/g')
endif
endif
# Trim any leading v from semver string
BUILD_TAG := $(shell echo $(BUILD_TAG) | sed 's/^v//')
# If BUILD_TAG is blank there's no tag on this commit
ifeq ($(strip $(BUILD_TAG)),)
BUILD_TAG := testing
endif
export BUILD_TAG
.PHONY: all
all: clean lint dep pull package index push
.PHONY: clean
clean:
rm -f Chart.yaml requirements.yaml
.PHONY: lint
lint: lint-yaml lint-helm
.PHONY: lint-yaml
lint-yaml: Chart.yaml requirements.yaml
yamllint .circleci/config.yml
yamllint Chart.yaml
yamllint values.yaml
yamllint requirements.yaml
.PHONY: lint-helm
lint-helm: Chart.yaml requirements.yaml
@helm lint .
.PHONY: dep
dep: lint
@helm dependency update
.PHONY: pull
pull:
@mkdir -p $(CHART_DIRECTORY)
gsutil -m rsync -d $(CHART_BUCKET) $(CHART_DIRECTORY)
Chart.yaml:
envsubst < Chart.yaml.in > Chart.yaml
requirements.yaml:
envsubst < requirements.yaml.in > requirements.yaml
.PHONY: package
package: lint Chart.yaml
ifndef CI
$(error This helm chart repository should only be run in CI)
endif
@[[ $(BUILD_TAG) =~ ^[0-9]+\.[0-9]+ ]] || { \
>&2 echo "ERROR: Refusing to package non-semver release: '$(BUILD_TAG)')" && \
exit 1; \
}
@helm package .
@mv $(CHART_NAME)-*.tgz $(CHART_DIRECTORY)
.PHONY: verify
verify: lint
@helm verify $(CHART_DIRECTORY)
.PHONY: index
index: lint
helm repo index $(CHART_DIRECTORY) --url $(CHART_URL)
.PHONY: push
push: package
gsutil -m rsync -d $(CHART_DIRECTORY) $(CHART_BUCKET)