Skip to content

Commit

Permalink
changed version to consequent dev version + added git dirty with upda…
Browse files Browse the repository at this point in the history
…ted make target
  • Loading branch information
ehearneRedHat committed Jun 10, 2024
1 parent 37c4465 commit c76b96e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_PATH := $(patsubst %/,%,$(dir $(MKFILE_PATH)))
GO ?= go
KUADRANT_NAMESPACE=kuadrant-system
VERSION := $(shell git rev-parse --short=7 HEAD)
GIT_HASH := $(shell git rev-parse --short=7 HEAD)
GIT_DIRTY := $(shell git diff --stat)

all: help

Expand Down Expand Up @@ -56,9 +57,9 @@ test: clean-cov fmt vet $(GINKGO)
## install: Build and install kuadrantctl binary ($GOBIN or GOPATH/bin)
.PHONY : install
install: fmt vet
ifneq ($(VERSION),)
GOBIN=$(PROJECT_PATH)/bin $(GO) install -ldflags "-X 'github.com/kuadrant/kuadrantctl/version.Version=dev - $(VERSION)'"
else
ifneq ($(GIT_HASH),$(GIT_DIRTY))
GOBIN=$(PROJECT_PATH)/bin $(GO) install -ldflags "-X 'github.com/kuadrant/kuadrantctl/version.GitDirty=$(GIT_DIRTY)' -X 'github.com/kuadrant/kuadrantctl/version.GitHash=$(GIT_HASH)'"
else
GOBIN=$(PROJECT_PATH)/bin $(GO) install
endif

Expand Down
15 changes: 14 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,18 @@ limitations under the License.
package version

var (
Version = "v0.0.0"
// This variable shows the user any additional changes to files made that aren't on the branch.
GitDirty string
// This variable shows the commit hash of the repo so they can confirm they are on latest or specific version of the branch.
GitHash string
// This variable is dependent on what the current release is e.g. if it is v0.2.3 then this variable, outside of releases, will be v0.2.4-dev .
Version = "v0.2.4-dev"
)

func init() {
if GitDirty != "" && GitHash != "" {
Version += " (" + GitHash + " - " + GitDirty + ")"
} else if GitDirty == "" {
Version += " (" + GitHash + ")"
}
}

0 comments on commit c76b96e

Please sign in to comment.