github.com/appscode/helm@v3.0.0-alpha.1+incompatible/Makefile (about) 1 BINDIR := $(CURDIR)/bin 2 DIST_DIRS := find * -type d -exec 3 TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64 4 BINNAME ?= helm 5 6 GOPATH = $(shell go env GOPATH) 7 DEP = $(GOPATH)/bin/dep 8 GOX = $(GOPATH)/bin/gox 9 GOIMPORTS = $(GOPATH)/bin/goimports 10 GOLANGCI_LINT = $(GOPATH)/bin/golangci-lint 11 12 # go option 13 PKG := ./... 14 TAGS := 15 TESTS := . 16 TESTFLAGS := 17 LDFLAGS := -w -s 18 GOFLAGS := 19 SRC := $(shell find . -type f -name '*.go' -print) 20 21 # Required for globs to work correctly 22 SHELL = /bin/bash 23 24 GIT_COMMIT = $(shell git rev-parse HEAD) 25 GIT_SHA = $(shell git rev-parse --short HEAD) 26 GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) 27 GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") 28 29 ifdef VERSION 30 BINARY_VERSION = $(VERSION) 31 endif 32 BINARY_VERSION ?= ${GIT_TAG} 33 34 # Only set Version if building a tag or VERSION is set 35 ifneq ($(BINARY_VERSION),) 36 LDFLAGS += -X helm.sh/helm/internal/version.version=${BINARY_VERSION} 37 endif 38 39 # Clear the "unreleased" string in BuildMetadata 40 ifneq ($(GIT_TAG),) 41 LDFLAGS += -X helm.sh/helm/internal/version.metadata= 42 endif 43 LDFLAGS += -X helm.sh/helm/internal/version.gitCommit=${GIT_COMMIT} 44 LDFLAGS += -X helm.sh/helm/internal/version.gitTreeState=${GIT_DIRTY} 45 46 .PHONY: all 47 all: build 48 49 # ------------------------------------------------------------------------------ 50 # build 51 52 .PHONY: build 53 build: $(BINDIR)/$(BINNAME) 54 55 $(BINDIR)/$(BINNAME): $(SRC) vendor 56 go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(BINNAME) helm.sh/helm/cmd/helm 57 58 # ------------------------------------------------------------------------------ 59 # test 60 61 .PHONY: test 62 test: build 63 test: TESTFLAGS += -race -v 64 test: test-style 65 test: test-unit 66 67 .PHONY: test-unit 68 test-unit: vendor 69 @echo 70 @echo "==> Running unit tests <==" 71 HELM_HOME=/no_such_dir go test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS) 72 73 .PHONY: test-coverage 74 test-coverage: vendor 75 @echo 76 @echo "==> Running unit tests with coverage <==" 77 @ HELM_HOME=/no_such_dir ./scripts/coverage.sh 78 79 .PHONY: test-style 80 test-style: vendor $(GOLANGCI_LINT) 81 $(GOLANGCI_LINT) run 82 @scripts/validate-license.sh 83 84 .PHONY: verify-docs 85 verify-docs: build 86 @scripts/verify-docs.sh 87 88 .PHONY: coverage 89 coverage: 90 @scripts/coverage.sh 91 92 .PHONY: format 93 format: $(GOIMPORTS) 94 go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w -local helm.sh/helm 95 96 # ------------------------------------------------------------------------------ 97 # dependencies 98 99 .PHONY: bootstrap 100 bootstrap: vendor 101 102 $(DEP): 103 go get -u github.com/golang/dep/cmd/dep 104 105 $(GOX): 106 go get -u github.com/mitchellh/gox 107 108 $(GOLANGCI_LINT): 109 go get -u github.com/golangci/golangci-lint/cmd/golangci-lint 110 111 $(GOIMPORTS): 112 go get -u golang.org/x/tools/cmd/goimports 113 114 # install vendored dependencies 115 vendor: Gopkg.lock 116 $(DEP) ensure -v --vendor-only 117 118 # update vendored dependencies 119 Gopkg.lock: Gopkg.toml 120 $(DEP) ensure -v --no-vendor 121 122 Gopkg.toml: $(DEP) 123 124 # ------------------------------------------------------------------------------ 125 # release 126 127 .PHONY: build-cross 128 build-cross: LDFLAGS += -extldflags "-static" 129 build-cross: vendor 130 build-cross: $(GOX) 131 CGO_ENABLED=0 $(GOX) -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' helm.sh/helm/cmd/helm 132 133 .PHONY: dist 134 dist: 135 ( \ 136 cd _dist && \ 137 $(DIST_DIRS) cp ../LICENSE {} \; && \ 138 $(DIST_DIRS) cp ../README.md {} \; && \ 139 $(DIST_DIRS) tar -zcf helm-${VERSION}-{}.tar.gz {} \; && \ 140 $(DIST_DIRS) zip -r helm-${VERSION}-{}.zip {} \; \ 141 ) 142 143 .PHONY: checksum 144 checksum: 145 for f in _dist/*.{gz,zip} ; do \ 146 shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \ 147 done 148 149 # ------------------------------------------------------------------------------ 150 151 .PHONY: docs 152 docs: build 153 @scripts/update-docs.sh 154 155 .PHONY: clean 156 clean: 157 @rm -rf $(BINDIR) ./_dist 158 159 .PHONY: info 160 info: 161 @echo "Version: ${VERSION}" 162 @echo "Git Tag: ${GIT_TAG}" 163 @echo "Git Commit: ${GIT_COMMIT}" 164 @echo "Git Tree State: ${GIT_DIRTY}"