Skip to content

Commit f8a8606

Browse files
author
NETIZEN-11
committed
build: Implement semantic versioning in build system
- Use git describe to generate semantic version from tags - Inject version into binary via ldflags at build time - Support development builds with commit hash fallback - Ensure version consistency across all architectures - Follow semantic versioning format (vMAJOR.MINOR.PATCH) Part of #4450 - Build & Versioning Setup Signed-off-by: NETIZEN-11 <kumarnitesh121411@gmail.com>
1 parent 1de6827 commit f8a8606

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ YEAR_GEN := $(shell date '+%Y')
2121

2222
GOBIN := $(shell go env GOPATH)/bin
2323
GIT_COMMIT := $(shell git rev-parse --short HEAD)
24+
# Use git describe to get semantic version, fallback to commit hash for dev builds
25+
VERSION := $(shell git describe --tags --match='v*' --abbrev=0 2>/dev/null || echo "v0.0.0-dev+${GIT_COMMIT}")
2426

2527
export KPT_FN_WASM_RUNTIME ?= nodejs
2628

27-
LDFLAGS := -ldflags "-X github.com/kptdev/kpt/run.version=${GIT_COMMIT}
29+
LDFLAGS := -ldflags "-X github.com/kptdev/kpt/run.version=${VERSION}
2830
ifeq ($(OS),Windows_NT)
2931
# Do nothing
3032
else

0 commit comments

Comments
 (0)