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 11, 2024
1 parent 37c4465 commit d198cc8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
29 changes: 23 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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)

all: help

Expand Down Expand Up @@ -56,11 +55,29 @@ 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
GOBIN=$(PROJECT_PATH)/bin $(GO) install
endif
@set -e; \
GIT_SHA=$$(git rev-parse --short=7 HEAD 2>/dev/null) || { \
GIT_HASH=$${GITHUB_SHA:-NO_SHA}; \
IS_DIRTY=false; \
}; \
if [ -z "$$GIT_HASH" ]; then \
GIT_DIRTY=$$(git diff --stat); \
if [ -n "$$GIT_DIRTY" ]; then \
GIT_HASH=$${GIT_SHA}-dirty; \
IS_DIRTY=true; \
else \
GIT_HASH=$${GIT_SHA}; \
IS_DIRTY=false; \
fi; \
fi; \
LDFLAGS="-X 'github.com/kuadrant/kuadrantctl/version.GitHash=$$GIT_HASH'"; \
if [ "$$IS_DIRTY" = true ]; then \
LDFLAGS="$$LDFLAGS -X 'github.com/kuadrant/kuadrantctl/version.GitDirty=true'"; \
else \
LDFLAGS="$$LDFLAGS -X 'github.com/kuadrant/kuadrantctl/version.GitDirty=false'"; \
fi; \
GOBIN=$(PROJECT_PATH)/bin $(GO) install -ldflags "$$LDFLAGS";


.PHONY: prepare-local-cluster
prepare-local-cluster: $(KIND) ## Deploy locally kuadrant operator from the current code
Expand Down
11 changes: 10 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ limitations under the License.
*/
package version

import "fmt"

var (
Version = "v0.0.0"
// 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() {
Version = fmt.Sprintf("%s (%s)", Version, GitHash)
}

0 comments on commit d198cc8

Please sign in to comment.