Skip to content

Commit e4b50e3

Browse files
committedMay 8, 2020
feat: add build flags to opm to show version information
1 parent d21c6e7 commit e4b50e3

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎Makefile

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
11
GO := GOFLAGS="-mod=vendor" go
2-
CMDS := $(addprefix bin/, $(shell ls ./cmd))
2+
CMDS := $(addprefix bin/, $(shell ls ./cmd | grep -v opm))
3+
OPM := $(addprefix bin/, opm)
34
SPECIFIC_UNIT_TEST := $(if $(TEST),-run $(TEST),)
5+
PKG := github.com/operator-framework/operator-registry
6+
GIT_COMMIT := $(shell git rev-parse --short HEAD)
7+
OPM_VERSION := $(shell cat OPM_VERSION)
8+
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
9+
410

511
.PHONY: all
612
all: clean test build
713

814
$(CMDS):
915
$(GO) build $(extra_flags) -o $@ ./cmd/$(notdir $@)
16+
$(OPM): opm_version_flags=-ldflags "-X '$(PKG)/cmd/opm/version.gitCommit=$(GIT_COMMIT)' -X '$(PKG)/cmd/opm/version.opmVersion=$(OPM_VERSION)' -X '$(PKG)/cmd/opm/version.buildDate=$(BUILD_DATE)'"
17+
$(OPM):
18+
$(GO) build $(opm_version_flags) $(extra_flags) -o $@ ./cmd/$(notdir $@)
1019

1120
.PHONY: build
12-
build: clean $(CMDS)
21+
build: clean $(CMDS) $(OPM)
1322

1423
.PHONY: static
1524
static: extra_flags=-ldflags '-w -extldflags "-static"'

‎OPM_VERSION

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.12.3

0 commit comments

Comments
 (0)
Please sign in to comment.