|
| 1 | +HELM_HOME ?= $(shell helm home) |
1 | 2 | BINARY := helm-set-status |
| 3 | +VERSION := $(shell sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml) |
2 | 4 |
|
3 | | -HELM_PLUGIN := $(shell helm env | sed -n -e 's/HELM_PLUGINS=[ "]*\([^"]*\).*/\1/p') |
4 | | -HELM_PLUGIN_PATH ?= $(HELM_PLUGIN)/$(BINARY) |
| 5 | +HELM_3_PLUGINS := $(shell helm env HELM_PLUGINS) |
| 6 | +LDFLAGS := -X main.version=${VERSION} |
5 | 7 |
|
6 | | -VERSION := $(shell sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml) |
7 | | -LDFLAGS := "-X main.version=${VERSION} -extldflags -static -w -s" |
8 | | -TAGS := "static_build netcgo osusergo" |
9 | | -OS_PLATFORM := $(shell uname -sp | tr '[:upper:] ' '[:lower:]-' | sed 's/x86_64/amd64/') |
| 8 | +GO ?= go |
10 | 9 |
|
11 | | -GO111MODULE = on |
12 | | -CGO_ENABLED = 1 |
| 10 | +.PHONY: format |
| 11 | +format: |
| 12 | + test -z "$$(find . -type f -o -name '*.go' -exec gofmt -d {} + | tee /dev/stderr)" || \ |
| 13 | + test -z "$$(find . -type f -o -name '*.go' -exec gofmt -w {} + | tee /dev/stderr)" |
13 | 14 |
|
14 | 15 | .PHONY: install |
15 | 16 | install: build |
16 | | - [ -e $(HELM_PLUGIN_PATH) ] || mkdir -p $(HELM_PLUGIN_PATH) |
17 | | - cp bin/$(BINARY) $(HELM_PLUGIN_PATH)/ |
18 | | - cp plugin.yaml $(HELM_PLUGIN_PATH)/ |
19 | | - |
20 | | -.PHONY: package |
21 | | -package: build |
22 | | - [ -e dist ] || mkdir -p dist |
23 | | - tar -czvf dist/$(BINARY)-$(OS_PLATFORM).tgz -C bin/ helm-set-status |
24 | | - |
25 | | -.PHONY: build |
26 | | -build: |
27 | | - go build -o bin/$(BINARY) -tags $(TAGS) -ldflags $(LDFLAGS) ./cmd/helm-set-status |
| 17 | + mkdir -p $(HELM_3_PLUGINS)/helm-set-status/bin |
| 18 | + cp bin/$(BINARY) $(HELM_3_PLUGINS)/helm-set-status/bin |
| 19 | + cp plugin.yaml $(HELM_3_PLUGINS)/helm-set-status/ |
28 | 20 |
|
29 | 21 | .PHONY: lint |
30 | 22 | lint: |
31 | | - golangci-lint run -v ./pkg/... ./cmd/... |
| 23 | + scripts/update-gofmt.sh |
| 24 | + scripts/verify-gofmt.sh |
| 25 | + scripts/verify-govet.sh |
| 26 | + scripts/verify-staticcheck.sh |
| 27 | + |
| 28 | +.PHONY: build |
| 29 | +build: lint |
| 30 | + mkdir -p bin/ |
| 31 | + go build -v -o bin/$(BINARY) -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
32 | 32 |
|
33 | 33 | .PHONY: test |
34 | 34 | test: |
35 | | - go test -v ./cmd/... ./pkg/... |
| 35 | + go test -v ./... -coverprofile cover.out -race |
| 36 | + go tool cover -func cover.out |
| 37 | + |
| 38 | +.PHONY: bootstrap |
| 39 | +bootstrap: |
| 40 | + go mod download |
| 41 | + command -v staticcheck || go install honnef.co/go/tools/cmd/staticcheck@latest |
| 42 | + |
| 43 | +.PHONY: dist |
| 44 | +dist: export COPYFILE_DISABLE=1 #teach OSX tar to not put ._* files in tar archive |
| 45 | +dist: export CGO_ENABLED=0 |
| 46 | +dist: |
| 47 | + rm -rf build/$(BINARY)/* release/* |
| 48 | + mkdir -p build/$(BINARY)/bin release/ |
| 49 | + cp README.md LICENSE plugin.yaml build/$(BINARY) |
| 50 | + GOOS=linux GOARCH=amd64 $(GO) build -o build/$(BINARY)/bin/$(BINARY) -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 51 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-linux-amd64.tgz $(BINARY)/ |
| 52 | + GOOS=linux GOARCH=arm64 $(GO) build -o build/$(BINARY)/bin/$(BINARY) -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 53 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-linux-arm64.tgz $(BINARY)/ |
| 54 | + GOOS=freebsd GOARCH=amd64 $(GO) build -o build/$(BINARY)/bin/$(BINARY) -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 55 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-freebsd-amd64.tgz $(BINARY)/ |
| 56 | + GOOS=darwin GOARCH=amd64 $(GO) build -o build/$(BINARY)/bin/$(BINARY) -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 57 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-macos-amd64.tgz $(BINARY)/ |
| 58 | + GOOS=darwin GOARCH=arm64 $(GO) build -o build/$(BINARY)/bin/$(BINARY) -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 59 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-macos-arm64.tgz $(BINARY)/ |
| 60 | + rm build/$(BINARY)/bin/$(BINARY) |
| 61 | + GOOS=windows GOARCH=amd64 $(GO) build -o build/$(BINARY)/bin/$(BINARY).exe -trimpath -ldflags="$(LDFLAGS)" ./cmd/helm-set-status |
| 62 | + tar -C build/ -zcvf $(CURDIR)/release/helm-set-status-windows-amd64.tgz $(BINARY)/ |
| 63 | + rm -rf build/ |
| 64 | + |
| 65 | +# Manual release process - CI uses goreleaser to do multiarch compilation and release |
| 66 | +.PHONY: release |
| 67 | +release: lint dist |
| 68 | + scripts/release.sh v$(VERSION) |
| 69 | + |
| 70 | +# Test for the plugin installation with `helm plugin install -v THIS_BRANCH` works |
| 71 | +# Useful for verifying modified `install-binary.sh` still works against various environments |
| 72 | +.PHONY: test-plugin-installation |
| 73 | +test-plugin-installation: |
| 74 | + docker build -f testdata/Dockerfile.install . |
0 commit comments