-
Notifications
You must be signed in to change notification settings - Fork 403
/
Makefile
234 lines (196 loc) · 7.81 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
VERSION ?= 0.16.2
REVISION := $(shell git rev-parse --short HEAD;)
BINDIR := $(CURDIR)/bin
BINNAME ?= chartmuseum
# Required for globs to work correctly
SHELL = /usr/bin/env bash
TARGETS := darwin/amd64 darwin/arm64 linux/amd64 linux/386 linux/arm linux/arm64 linux/mips64le linux/ppc64le linux/s390x windows/amd64 linux/loong64
TARGET_OBJS ?= darwin-amd64.tar.gz darwin-amd64.tar.gz.sha256sum darwin-arm64.tar.gz darwin-arm64.tar.gz.sha256sum linux-amd64.tar.gz linux-amd64.tar.gz.sha256sum linux-386.tar.gz linux-386.tar.gz.sha256sum linux-arm.tar.gz linux-arm.tar.gz.sha256sum linux-arm64.tar.gz linux-arm64.tar.gz.sha256sum linux-mips64le.tar.gz linux-mips64le.tar.gz.sha256sum linux-ppc64le.tar.gz linux-ppc64le.tar.gz.sha256sum linux-s390x.tar.gz linux-s390x.tar.gz.sha256sum windows-amd64.zip windows-amd64.zip.sha256sum linux-loong64.tar.gz linux-loong64.tar.gz.sha256sum
DIST_DIRS := find * -type d -exec
GOBIN = $(shell go env GOBIN)
ifeq ($(GOBIN),)
GOBIN = $(shell go env GOPATH)/bin
endif
GOX = $(GOBIN)/gox
CM_LOADTESTING_HOST ?= http://localhost:8080
$(GOX):
(cd /; GO111MODULE=on go install github.com/mitchellh/gox@latest)
.PHONY: bootstrap
bootstrap: export GO111MODULE=on
bootstrap: export GOPROXY=$(MOD_PROXY_URL)
bootstrap:
@go mod download && go mod vendor
.PHONY: build
build: build-linux build-mac build-mac-arm build-windows build-linux-mips build-linux-loongarch64
.PHONY: build-windows
build-windows: export GOOS=windows
build-windows: export GOARCH=amd64
build-windows: export GO111MODULE=on
build-windows: export GOPROXY=$(MOD_PROXY_URL)
build-windows:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/windows/amd64/chartmuseum cmd/chartmuseum/main.go # windows
sha256sum bin/windows/amd64/chartmuseum || shasum -a 256 bin/windows/amd64/chartmuseum
.PHONY: build-linux
build-linux: export GOOS=linux
build-linux: export GOARCH=amd64
build-linux: export CGO_ENABLED=0
build-linux: export GO111MODULE=on
build-linux: export GOPROXY=$(MOD_PROXY_URL)
build-linux:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/amd64/chartmuseum cmd/chartmuseum/main.go # linux
sha256sum bin/linux/amd64/chartmuseum || shasum -a 256 bin/linux/amd64/chartmuseum
.PHONY: build-linux-mips
build-linux-mips: export GOOS=linux
build-linux-mips: export GOARCH=mips64le
build-linux-mips: export CGO_ENABLED=0
build-linux-mips: export GO111MODULE=on
build-linux-mips: export GOPROXY=$(MOD_PROXY_URL)
build-linux-mips:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/mips64/chartmuseum cmd/chartmuseum/main.go # linux
sha256sum bin/linux/mips64/chartmuseum || shasum -a 256 bin/linux/mips64/chartmuseum
.PHONY: build-linux-loongarch64
build-linux-loongarch64: export GOOS=linux
build-linux-loongarch64: export GOARCH=loong64
build-linux-loongarch64: export CGO_ENABLED=0
build-linux-loongarch64: export GO111MODULE=on
build-linux-loongarch64: export GOPROXY=$(MOD_PROXY_URL)
build-linux-loongarch64:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/loongarch64/chartmuseum cmd/chartmuseum/main.go # linux
sha256sum bin/linux/loongarch64/chartmuseum || shasum -a 256 bin/linux/loongarch64/chartmuseum
.PHONY: build-armv7
build-armv7: export GOOS=linux
build-armv7: export GOARCH=arm
build-armv7: export GOARM=7
build-armv7: export CGO_ENABLED=0
build-armv7: export GO111MODULE=on
build-armv7: export GOPROXY=$(MOD_PROXY_URL)
build-armv7:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/linux/armv7/chartmuseum cmd/chartmuseum/main.go # linux
.PHONY: build-mac
build-mac: export GOOS=darwin
build-mac: export GOARCH=amd64
build-mac: export CGO_ENABLED=0
build-mac: export GO111MODULE=on
build-mac: export GOPROXY=$(MOD_PROXY_URL)
build-mac:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/darwin/amd64/chartmuseum cmd/chartmuseum/main.go # mac osx
sha256sum bin/darwin/amd64/chartmuseum || shasum -a 256 bin/darwin/amd64/chartmuseum
.PHONY: build-mac-arm
build-mac-arm: export GOOS=darwin
build-mac-arm: export GOARCH=arm64
build-mac-arm: export CGO_ENABLED=0
build-mac-arm: export GO111MODULE=on
build-mac-arm: export GOPROXY=$(MOD_PROXY_URL)
build-mac-arm:
go build -v --ldflags="-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION)" \
-o bin/darwin/arm64/chartmuseum cmd/chartmuseum/main.go # mac osx
sha256sum bin/darwin/arm64/chartmuseum || shasum -a 256 bin/darwin/arm64/chartmuseum
.PHONY: clean
clean:
@git status --ignored --short | grep '^!! ' | sed 's/!! //' | xargs rm -rf
.PHONY: setup-test-environment
setup-test-environment:
@./scripts/setup-test-environment.sh
.PHONY: test
test: export CGO_ENABLED=0
test: export GO111MODULE=on
test: export GOPROXY=$(MOD_PROXY_URL)
test: setup-test-environment
@./scripts/test.sh
.PHONY: startloadtest
startloadtest:
@cd loadtesting && pipenv install
@cd loadtesting && pipenv run locust --host $(CM_LOADTESTING_HOST)
.PHONY: covhtml
covhtml:
@go tool cover -html=.cover/cover.out
.PHONY: acceptance
acceptance: setup-test-environment
@./scripts/acceptance.sh
.PHONY: run
run:
@rm -rf .chartstorage/
@bin/darwin/amd64/chartmuseum --debug --port=8080 --storage="local" \
--storage-local-rootdir=".chartstorage/"
.PHONY: tree
tree:
@tree -I vendor
# https://github.com/hirokidaichi/goviz/pull/8
.PHONY: goviz
goviz:
#@go get -u github.com/RobotsAndPencils/goviz
@goviz -i helm.sh/chartmuseum/cmd/chartmuseum -l | dot -Tpng -o goviz.png
.PHONY: get-version
get-version:
@echo $(VERSION)
.PHONY: build-cross
build-cross: $(GOX)
GO111MODULE=on CGO_ENABLED=0 $(GOX) -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags='-w -X main.Version=$(VERSION) -X main.Revision=$(REVISION) -extldflags "-static"' ./cmd/chartmuseum
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf chartmuseum-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r chartmuseum-${VERSION}-{}.zip {} \; && \
for f in `find *.zip`; do if [[ $${f} != *"windows"* ]]; then rm -f $${f}; fi; done \
)
.PHONY: fetch-dist
fetch-dist:
mkdir -p _dist
cd _dist && \
for obj in ${TARGET_OBJS} ; do \
curl -sSL -o chartmuseum-v${VERSION}-$${obj} https://get.helm.sh/chartmuseum-v${VERSION}-$${obj} ; \
done
# The contents of the .sha256sum file are compatible with tools like
# shasum. For example, using the following command will verify
# the file chartmuseum-v0.13.1-darwin-amd64.tar.gz:
# shasum -a 256 -c chartmuseum-v0.13.1-darwin-amd64.tar.gz.sha256sum
.PHONY: checksum
checksum:
for f in $$(ls _dist/*.{gz,spdx,zip} 2>/dev/null) ; do \
echo "Creating $${f}.sha256sum" ; \
shasum -a 256 "$${f}" | sed 's/_dist\///' > "$${f}.sha256sum" ; \
done
.PHONY: sbom
sbom:
@./scripts/sbom.sh
.PHONY: cosign
cosign:
for f in $$(ls _dist/*.{gz,zip,sha256sum,spdx} 2>/dev/null) ; do \
echo "Creating $${f}.sig" ; \
cosign sign-blob --yes --output-file "$${f}.sig" "$${f}"; \
done
.PHONY: sign
sign:
for f in $$(ls _dist/*.{gz,zip,sha256sum} 2>/dev/null) ; do \
gpg --armor --detach-sign $${f} ; \
done
.PHONY: release-notes
release-notes:
@if [ ! -d "./_dist" ]; then \
echo "please run 'make fetch-dist' first" && \
exit 1; \
fi
@if [ -z "${PREVIOUS_RELEASE}" ]; then \
echo "please set PREVIOUS_RELEASE environment variable" \
&& exit 1; \
fi
@./scripts/release-notes.sh ${PREVIOUS_RELEASE} v${VERSION}
.PHONY: lint
lint: export CGO_ENABLED=0
lint: export GO111MODULE=on
lint:
@if [ -x "$$(command -v golangci-lint)" ]; then \
golangci-lint run; \
else \
echo "golangci-lint is not installed, please install it from https://golangci-lint.run/usage/install/"; \
exit 1; \
fi