This repository has been archived by the owner on Apr 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# adapted from the hack scripts in kubernetes/kubernetes | ||
|
||
GIT_COMMIT:=$(shell git rev-parse "HEAD^{commit}" 2>/dev/null) | ||
|
||
# the raw git version from `git describe` -- our starting point | ||
GIT_VERSION_RAW:=$(shell git describe --tags --abbrev=14 "$(GIT_COMMIT)^{commit}" 2>/dev/null) | ||
|
||
# use the number of dashes in the raw version to figure out what kind of | ||
# version this is, and turn it into a semver-compatible version | ||
DASHES_IN_VERSION:=$(shell echo "$(GIT_VERSION_RAW)" | sed "s/[^-]//g") | ||
|
||
# just use the raw version by default | ||
GIT_VERSION:=$(GIT_VERSION_RAW) | ||
|
||
ifeq ($(DASHES_IN_VERSION), ---) | ||
# we have a distance to a subversion (v1.1.0-subversion-1-gCommitHash) | ||
GIT_VERSION:=$(shell echo "$(GIT_VERSION_RAW)" | sed "s/-\([0-9]\{1,\}\)-g\([0-9a-f]\{14\}\)$$/.\1\+\2/") | ||
endif | ||
ifeq ($(DASHES_IN_VERSION), --) | ||
# we have distance to base tag (v1.1.0-1-gCommitHash) | ||
GIT_VERSION:=$(shell echo "$(GIT_VERSION_RAW)" | sed "s/-g\([0-9a-f]\{14\}\)$$/+\1/") | ||
endif | ||
|
||
# figure out if we have new or changed files | ||
ifeq ($(shell git status --porcelain 2>/dev/null), "") | ||
GIT_TREE_STATE:=clean | ||
else | ||
# append the -dirty manually, since `git describe --dirty` only considers | ||
# changes to existing files | ||
GIT_TREE_STATE:=dirty | ||
GIT_VERSION:=$(GIT_VERSION)-dirty | ||
endif | ||
|
||
# construct a "shorter" version without the commit info, etc for use as container image tag, etc | ||
VERSION?=$(shell echo "$(GIT_VERSION)" | grep -E -o '^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+(-(alpha|beta)\.[[:digit:]]+)?') | ||
|
||
# construct the build date, taking into account SOURCE_DATE_EPOCH, which is | ||
# used for the purpose of reproducible builds | ||
ifdef SOURCE_DATE_EPOCH | ||
BUILD_DATE:=$(shell date --date=@${SOURCE_DATE_EPOCH} -u +'%Y-%m-%dT%H:%M:%SZ') | ||
else | ||
BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') | ||
endif | ||
|
||
# set the build information version ldflags (but not other ldflags) | ||
VERSION_LDFLAGS:=-X k8s.io/cloud-provider-baiducloud/vendor/k8s.io/kubernetes/pkg/version.gitVersion=$(GIT_VERSION) -X k8s.io/cloud-provider-baiducloud/vendor/k8s.io/kubernetes/pkg/version.gitCommit=$(GIT_COMMIT) -X k8s.io/cloud-provider-baiducloud/vendor/k8s.io/kubernetes/pkg/version.gitTreeState=$(GIT_TREE_STATE) -X k8s.io/cloud-provider-baiducloud/vendor/k8s.io/kubernetes/pkg/version.buildDate=$(BUILD_DATE) | ||
|
||
export VERSION | ||
export VERSION_LDFLAGS | ||
|
||
# print out a summary of the current version info | ||
version-info: | ||
@echo "Version: $(GIT_VERSION) ($(VERSION))" | ||
@echo " built from $(GIT_COMMIT) ($(GIT_TREE_STATE))" | ||
@echo " built on $(BUILD_DATE)" | ||
.PHONY: version-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters