diff --git a/Makefile b/Makefile index 39c321d..0d25eb2 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,15 @@ +SHELL := /bin/sh +BINARY_NAME := kubectl-permissions +REV := $(shell git rev-parse --short HEAD 2> /dev/null || echo 'unknown') +GIT_TREE_STATE := $(shell test -z "`git status --porcelain`" && echo "clean" || echo "dirty") + +VERSION ?= $(shell echo "$$(git for-each-ref refs/tags/ --count=1 --sort=-version:refname --format='%(refname:short)' 2>/dev/null)-dev+$(REV)-$(GIT_TREE_STATE)" | sed 's/^v//') + build: - go build -o kubectl-permissions -trimpath -ldflags "-X github.com/garethjevans/kubectl-permissions/pkg/version.Version=dev" cmd/kubectl-permissions.go + go build -o $(BINARY_NAME) -trimpath -ldflags "-X github.com/garethjevans/kubectl-permissions/pkg/version.Version=$(VERSION)" cmd/kubectl-permissions.go install: build - sudo cp -f kubectl-permissions /usr/local/bin + sudo cp -f $(BINARY_NAME) /usr/local/bin lint: golangci-lint run