feat: add commit count flag in pre-release version (#2870)

* feat: support commit count in pre-release version

* unexport version strings, correct semver

and shortern makefile lines

* add alpha tag immediately after release commit

Co-authored-by: Benjamin Elder <bentheelder@google.com>
This commit is contained in:
失眠是真滴难受
2022-09-02 07:12:07 +08:00
committed by GitHub
parent c6b929bd79
commit 9ad1341405
3 changed files with 27 additions and 14 deletions

View File

@@ -27,6 +27,8 @@ REPO_ROOT:=${CURDIR}
OUT_DIR=$(REPO_ROOT)/bin
# record the source commit in the binary, overridable
COMMIT?=$(shell git rev-parse HEAD 2>/dev/null)
# count the commits since the last release
COMMIT_COUNT?=$(shell git describe --tags | rev | cut -d- -f2 | rev)
################################################################################
# ========================= Setup Go With Gimme ================================
# go version to use for build etc.
@@ -54,7 +56,9 @@ KIND_BINARY_NAME?=kind
# - reproducible builds: -trimpath and -ldflags=-buildid=
# - smaller binaries: -w (trim debugger data, but not panics)
# - metadata: -X=... to bake in git commit
KIND_BUILD_FLAGS?=-trimpath -ldflags="-buildid= -w -X=sigs.k8s.io/kind/pkg/cmd/kind/version.GitCommit=$(COMMIT)"
KIND_VERSION_PKG:=sigs.k8s.io/kind/pkg/cmd/kind/version
KIND_BUILD_LD_FLAGS:=-X=$(KIND_VERSION_PKG).gitCommit=$(COMMIT) -X=$(KIND_VERSION_PKG).gitCommitCount=$(COMMIT_COUNT)
KIND_BUILD_FLAGS?=-trimpath -ldflags="-buildid= -w $(KIND_BUILD_LD_FLAGS)"
################################################################################
# ================================= Building ===================================
# standard "make" target -> builds