build: add more variables (#1136)

Add more variables and make it overridable so project maintainers
can customize the build of k9s.
mine
Alexandre Vicenzi 2021-06-04 16:26:29 +02:00 committed by GitHub
parent a631712c05
commit fe370747dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 10 deletions

View File

@ -1,11 +1,13 @@
NAME := k9s GO_FLAGS ?=
PACKAGE := github.com/derailed/$(NAME) NAME := k9s
GIT := $(shell git rev-parse --short HEAD) OUTPUT_BIN ?= execs/${NAME}
PACKAGE := github.com/derailed/$(NAME)
GIT_REV ?= $(shell git rev-parse --short HEAD)
SOURCE_DATE_EPOCH ?= $(shell date +%s) SOURCE_DATE_EPOCH ?= $(shell date +%s)
DATE := $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ") DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
VERSION ?= v0.24.10 VERSION ?= v0.24.10
IMG_NAME := derailed/k9s IMG_NAME := derailed/k9s
IMAGE := ${IMG_NAME}:${VERSION} IMAGE := ${IMG_NAME}:${VERSION}
default: help default: help
@ -17,9 +19,9 @@ cover: ## Run test coverage suite
@go tool cover --html=cov.out @go tool cover --html=cov.out
build: ## Builds the CLI build: ## Builds the CLI
@go build \ @go build ${GO_FLAGS} \
-ldflags "-w -s -X ${PACKAGE}/cmd.version=${VERSION} -X ${PACKAGE}/cmd.commit=${GIT} -X ${PACKAGE}/cmd.date=${DATE}" \ -ldflags "-w -s -X ${PACKAGE}/cmd.version=${VERSION} -X ${PACKAGE}/cmd.commit=${GIT_REV} -X ${PACKAGE}/cmd.date=${DATE}" \
-a -tags netgo -o execs/${NAME} main.go -a -tags netgo -o ${OUTPUT_BIN} main.go
kubectl-stable-version: ## Get kubectl latest stable version kubectl-stable-version: ## Get kubectl latest stable version
@curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt @curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt