|
1 | | -.PHONY: all build gen-demo lint |
2 | | -all: build |
| 1 | +SHELL:=/bin/bash |
3 | 2 |
|
| 3 | +export GIT_VERSION = $(shell git describe --tags --always) |
| 4 | +export GIT_COMMIT = $(shell git rev-parse HEAD) |
| 5 | +export GIT_COMMIT_TIME = $(shell TZ=UTC git show -s --format=%cd --date=format-local:%Y-%m-%dT%TZ) |
| 6 | +export GIT_TREE_STATE = $(shell sh -c '(test -n "$(shell git status -s)" && echo "dirty") || echo "clean"') |
| 7 | + |
| 8 | +REPO = $(shell go list -m) |
| 9 | +GO_BUILD_ARGS = \ |
| 10 | + -gcflags "all=-trimpath=$(shell dirname $(shell pwd))" \ |
| 11 | + -asmflags "all=-trimpath=$(shell dirname $(shell pwd))" \ |
| 12 | + -ldflags " \ |
| 13 | + -s \ |
| 14 | + -w \ |
| 15 | + -X '$(REPO)/internal/version.GitVersion=$(GIT_VERSION)' \ |
| 16 | + -X '$(REPO)/internal/version.GitCommit=$(GIT_COMMIT)' \ |
| 17 | + -X '$(REPO)/internal/version.GitCommitTime=$(GIT_COMMIT_TIME)' \ |
| 18 | + -X '$(REPO)/internal/version.GitTreeState=$(GIT_TREE_STATE)' \ |
| 19 | + " \ |
| 20 | + |
| 21 | +.PHONY: all |
| 22 | +all: install |
| 23 | + |
| 24 | +.PHONY: build |
4 | 25 | build: |
5 | | - go build -o bin/kubectl-operator |
| 26 | + go build $(GO_BUILD_ARGS) -o bin/kubectl-operator |
6 | 27 |
|
| 28 | +.PHONY: install |
7 | 29 | install: build |
8 | 30 | install bin/kubectl-operator $(shell go env GOPATH)/bin |
9 | 31 |
|
| 32 | +.PHONY: gen-demo |
10 | 33 | gen-demo: |
11 | 34 | ./assets/demo/gen-demo.sh |
12 | 35 |
|
13 | | -GOLANGCI_LINT_VER = "1.29.0" |
| 36 | +.PHONY: lint |
14 | 37 | lint: |
15 | | -# scripts/golangci-lint-check.sh |
16 | | -ifneq (${GOLANGCI_LINT_VER}, "$(shell ./bin/golangci-lint --version 2>/dev/null | cut -b 27-32)") |
17 | | - @echo "golangci-lint missing or not version '${GOLANGCI_LINT_VER}', downloading..." |
18 | | - curl -sSfL "https://raw.githubusercontent.com/golangci/golangci-lint/v${GOLANGCI_LINT_VER}/install.sh" | sh -s -- -b ./bin "v${GOLANGCI_LINT_VER}" |
19 | | -endif |
20 | | - ./bin/golangci-lint --timeout 3m run |
| 38 | + source ./scripts/fetch.sh; fetch golangci-lint 1.29.0 && ./bin/golangci-lint --timeout 3m run |
| 39 | + |
| 40 | +.PHONY: release |
| 41 | +RELEASE_ARGS?=release --rm-dist --snapshot |
| 42 | +release: |
| 43 | + source ./scripts/fetch.sh; fetch goreleaser 0.141.0 && ./bin/goreleaser $(RELEASE_ARGS) |
0 commit comments