Fix kava version build tag for detached HEAD state (#1465)

* use tag for kava version if we are in a detached HEAD state; add
print-git-info target for displaying git data

* refactor to ignore any detached head state; rely on checkout of exact
tag
This commit is contained in:
Nick DeLuca 2023-02-02 13:20:02 -07:00 committed by GitHub
parent f9b353753c
commit 9d059f5ed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,9 +9,16 @@ GIT_COMMIT_SHORT := $(shell git rev-parse --short HEAD)
BRANCH_PREFIX := $(shell echo $(GIT_BRANCH) | sed 's/\/.*//g')# eg release, master, feat
EXACT_TAG := $(shell git describe --tags --exact-match 2> /dev/null)
RECENT_TAG := $(shell git describe --tags)
ifeq ($(BRANCH_PREFIX), release)
# we are on a release branch, set version to the last or current tag
VERSION := $(shell git describe --tags)# use current tag or most recent tag + number of commits + g + abbrivated commit
VERSION := $(RECENT_TAG)# use current tag or most recent tag + number of commits + g + abbrivated commit
VERSION_NUMBER := $(shell echo $(VERSION) | sed 's/^v//')# drop the "v" prefix for versions
else ifeq ($(EXACT_TAG), $(RECENT_TAG))
# we have a tag checked out directly
VERSION := $(RECENT_TAG)# use exact tag
VERSION_NUMBER := $(shell echo $(VERSION) | sed 's/^v//')# drop the "v" prefix for versions
else
# we are not on a release branch, and do not have clean tag history (etc v0.19.0-xx-gxx will not make sense to use)
@ -22,6 +29,10 @@ endif
TENDERMINT_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.* ::')
COSMOS_SDK_VERSION := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's:.* ::')
.PHONY: print-git-info
print-git-info:
@echo "branch $(GIT_BRANCH)\nbranch_prefix $(BRANCH_PREFIX)\ncommit $(GIT_COMMIT)\ncommit_short $(GIT_COMMIT_SHORT)"
.PHONY: print-version
print-version:
@echo "kava $(VERSION)\ntendermint $(TENDERMINT_VERSION)\ncosmos $(COSMOS_SDK_VERSION)"