-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
53 lines (44 loc) · 1.43 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
HELM_HOME ?= $(shell helm home)
HELM_PLUGIN_DIR ?= $(HELM_HOME)/plugins/helm-convert
VERSION := $(shell sed -n -e 's/version:[ "]*\([^"]*\).*/\1/p' plugin.yaml)
DIST := $(CURDIR)/_dist
LDFLAGS := "-X main.version=${VERSION}"
BINARY := "helm-convert"
DOCKER_IMAGE ?= containersol/helm-convert
DOCKER_TAG ?= latest
# go mod ftw
unexport GOPATH
.PHONY: install
install: build
cp $(BINARY) $(HELM_PLUGIN_DIR)
cp plugin.yaml $(HELM_PLUGIN_DIR)
.PHONY: build
build:
go build -o $(BINARY) -ldflags $(LDFLAGS) main.go
.PHONY: build.docker
build.docker:
docker build \
--build-arg LDFLAGS=$(LDFLAGS) \
--cache-from ${DOCKER_IMAGE} \
-t ${DOCKER_IMAGE}:$(DOCKER_TAG) .
.PHONY: dist
dist:
mkdir -p $(DIST)
GOOS=linux GOARCH=amd64 go build -o $(BINARY) -ldflags $(LDFLAGS) main.go
tar -zcvf $(DIST)/helm-convert_linux_$(VERSION).tar.gz $(BINARY) README.md LICENSE plugin.yaml
GOOS=darwin GOARCH=amd64 go build -o $(BINARY) -ldflags $(LDFLAGS) main.go
tar -zcvf $(DIST)/helm-convert_darwin_$(VERSION).tar.gz $(BINARY) README.md LICENSE plugin.yaml
GOOS=windows GOARCH=amd64 go build -o $(BINARY).exe -ldflags $(LDFLAGS) main.go
tar -zcvf $(DIST)/helm-convert_windows_$(VERSION).tar.gz $(BINARY).exe README.md LICENSE plugin.yaml
.PHONY: test-all
test-all: vet lint test
.PHONY: test
test:
go test -v -parallel=4 ./...
.PHONY: lint
lint:
@go get -u golang.org/x/lint/golint
go list ./... | xargs -n1 $${HOME}/go/bin/golint
.PHONY: vet
vet:
go vet ./...