Skip to content

Commit

Permalink
set the version during build
Browse files Browse the repository at this point in the history
  • Loading branch information
ehearneRedHat committed May 23, 2024
1 parent 6252feb commit 00b9b01
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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 @@ -41,8 +42,7 @@ test: fmt vet $(GINKGO)
## install: Build and install kuadrantctl binary ($GOBIN or GOPATH/bin)
.PHONY : install
install: fmt vet
$(MAKE) update-version
GOBIN=$(PROJECT_PATH)/bin $(GO) install
GOBIN=$(PROJECT_PATH)/bin $(GO) install -ldflags "-X 'github.com/kuadrant/kuadrantctl/version.Version=dev - $(VERSION)'"

.PHONY: prepare-local-cluster
prepare-local-cluster: $(KIND) ## Deploy locally kuadrant operator from the current code
Expand Down Expand Up @@ -75,10 +75,5 @@ fmt:
vet:
$(GO) vet ./...

.PHONY: update-version
update-version:
@commit_hash=$$(git rev-parse --short=7 HEAD); \
sed -i.bak 's/Version = "v0.0.0"/Version = "dev - '$${commit_hash}'"/' version/version.go && rm version/version.go.bak

# Include last to avoid changing MAKEFILE_LIST used above
include ./make/*.mk
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ limitations under the License.
package version

var (
Version = "v0.0.0"
Version string
)

0 comments on commit 00b9b01

Please sign in to comment.