Skip to content

Commit

Permalink
Fix --version flag (#3428)
Browse files Browse the repository at this point in the history
Our build scripts had regression: we were not passing version
information to `go build` correctly.

As a result running the binary with `--version` was not printing
version and commit sha:

```
OLM version:
git commit:
```

Signed-off-by: Mikalai Radchuk <[email protected]>
  • Loading branch information
m1kola authored Nov 1, 2024
1 parent 5a01f50 commit fb6694f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,18 @@ export CGO_ENABLED ?= 0
export GO111MODULE ?= on
export GIT_REPO := $(shell go list -m)
export GIT_COMMIT := $(shell git rev-parse HEAD)
export VERSION := $(shell cat OLM_VERSION)
export VERSION_PATH := ${GIT_REPO}/pkg/version

ifeq ($(origin VERSION), undefined)
VERSION := $(shell git describe --tags --always --dirty)
endif
export VERSION

# GO_BUILD flags are set with = to allow for re-evaluation of the variables
export GO_BUILD_ASMFLAGS = all=-trimpath=$(PWD)
export GO_BUILD_GCFLAGS = all=-trimpath=$(PWD)
export GO_BUILD_FLAGS = -mod=vendor -buildvcs=false
export GO_BUILD_LDFLAGS = -s -w -X '$(VERSION_PATH).version=$(VERSION)' -X '$(VERSION_PATH).gitCommit=$(GIT_COMMIT)' -extldflags "-static"
export GO_BUILD_LDFLAGS = -s -w -X '$(VERSION_PATH).OLMVersion=$(VERSION)' -X '$(VERSION_PATH).GitCommit=$(GIT_COMMIT)' -extldflags "-static"
export GO_BUILD_TAGS = json1

# GO_TEST flags are set with = to allow for re-evaluation of the variables
Expand Down Expand Up @@ -330,7 +334,6 @@ ifeq ($(PACKAGE_QUICKSTART), true)
endif

.PHONY: release
release: RELEASE_VERSION=v$(shell cat OLM_VERSION) #HELP Generate an OLM release (NOTE: before running release, bump the version in ./OLM_VERSION and push to master, then tag those builds in quay with the version in ./OLM_VERSION)
release: pull-opm manifests # pull the opm image to get the digest
@echo "Generating the $(RELEASE_VERSION) release"
docker pull $(IMAGE_REPO):$(RELEASE_VERSION)
Expand Down
1 change: 0 additions & 1 deletion OLM_VERSION

This file was deleted.

0 comments on commit fb6694f

Please sign in to comment.