-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbase.mk
More file actions
38 lines (32 loc) · 1.14 KB
/
base.mk
File metadata and controls
38 lines (32 loc) · 1.14 KB
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
GOLANGCI_VERSION ?= v2.11.2
TOOLS_BIN := $(shell mkdir -p build/tools && realpath build/tools)
VERSION = $(shell git tag -l --contains HEAD | head -n 1)
CHANGES = $(shell git status --porcelain --untracked-files=no)
ifneq ($(CHANGES),)
DIRTY = -dirty
endif
ifeq ($(VERSION),)
VERSION = v0.0.0-$(shell git rev-parse --short HEAD)$(DIRTY)
endif
GO_TAGS = -tags "netgo,osusergo"
LDFLAGS = -ldflags "-extldflags -s -w -X github.com/rancherlabs/slsactl/cmd.version=$(VERSION)"
GOLANGCI = $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
$(GOLANGCI):
rm -f $(TOOLS_BIN)/golangci-lint*
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/$(GOLANGCI_VERSION)/install.sh | sh -s -- -b $(TOOLS_BIN) $(GOLANGCI_VERSION)
mv $(TOOLS_BIN)/golangci-lint $(TOOLS_BIN)/golangci-lint-$(GOLANGCI_VERSION)
# go-install-tool will 'go install' any package $2 and install it as $1.
define go-install-tool
@[ -f $(1) ] || { \
set -e ;\
echo "Downloading $(2)" ;\
GOBIN=$(TOOLS_BIN) go install $(2) ;\
}
endef
verify-dirty:
ifneq ($(shell git status --porcelain --untracked-files=no),)
@echo worktree is dirty
@git --no-pager status
@git --no-pager diff
@exit 1
endif