This repository has been archived by the owner on Oct 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
91 lines (75 loc) · 1.88 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
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
HAS_TILT := $(shell command -v tilt;)
HAS_GHR := $(shell command -v ghr;)
IMAGE_NAME ?= servicemeshinterface/smi-metrics
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
ifdef RELEASE_VERSION
IMAGE := ${IMAGE_NAME}:${RELEASE_VERSION}
VERSION := $(shell echo ${RELEASE_VERSION} | cut -c2- )
else
IMAGE := ${IMAGE_NAME}:git-${GIT_COMMIT}
endif
.PHONY: release-bootstrap
release-bootstrap:
@echo "Installing Helm v2"
set -x; curl -L https://git.io/get_helm.sh | bash
@#Check for ghr
ifndef HAS_GHR
@echo "Installing ghr"
go get -u github.com/tcnksm/ghr
endif
.PHONY: bootstrap
bootstrap:
@# Bootstrap the required binaries
ifndef HAS_TILT
echo "Install tilt from https://docs.tilt.dev/install.html"
endif
.PHONY: lint
lint:
./bin/lint --verbose
.PHONY: test
test:
go test -cover -v -race ./...
.PHONY: vendor
vendor:
go mod vendor
.PHONY: dep
dep:
go mod download
tmp:
mkdir tmp
.PHONY: build-chart
build-chart: tmp release-bootstrap
ifndef RELEASE_VERSION
@echo "Missing RELEASE_VERSION, is this being run from CI?"
@exit 1
endif
cp -R chart tmp/smi-metrics
sed -i.bak 's/CHART_VERSION/${VERSION}/g' tmp/smi-metrics/Chart.yaml
for fname in $$(grep -rnl '$*' tmp/smi-metrics); do \
sed -i.bak 's/VERSION/${RELEASE_VERSION}/g' $$fname; \
done
helm package tmp/smi-metrics -d tmp --save=false
rm -rf tmp/smi-metrics/
.PHONY: dev
dev: bootstrap
tilt up
.PHONY: release
release: release-bootstrap build-chart
ifndef RELEASE_VERSION
@echo "Missing RELEASE_VERSION, is this being run from CI?"
@exit 1
endif
ifndef GITHUB_TOKEN
@echo "Requires a GITHUB_TOKEN with edit permissions for releases."
@exit 1
endif
ghr -u servicemeshinterface \
${RELEASE_VERSION} \
tmp/smi-metrics-*
.PHONY: push
push: build
docker push $(IMAGE)
.PHONY: build
build:
docker build -t $(IMAGE) .