From 709d49157a34833b8d2a72547fe7876d601307a1 Mon Sep 17 00:00:00 2001 From: Kimmo Lehto Date: Tue, 10 Oct 2023 15:42:37 +0300 Subject: [PATCH] Fix setting binary version during build Signed-off-by: Kimmo Lehto --- Makefile | 6 +++--- cmd/bootloose/version.go | 1 - main.go | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8981b97..60a7434 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ BIN_PREFIX := bootloose- all: bootloose bootloose: - go build -v $(BUILD_FLAGS) -o bootloose . + go build -v $(BUILD_FLAGS) -o bootloose main.go PLATFORMS := linux-amd64 linux-arm64 linux-arm darwin-amd64 darwin-arm64 bins := $(foreach platform, $(PLATFORMS), bin/$(BIN_PREFIX)$(platform)) @@ -27,10 +27,10 @@ $(bins): $(eval temp := $(subst -, ,$(subst $(BIN_PREFIX),,$(notdir $@)))) $(eval OS := $(word 1, $(subst -, ,$(temp)))) $(eval ARCH := $(word 2, $(subst -, ,$(temp)))) - GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ . + GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build $(BUILD_FLAGS) -o $@ main.go bin/%: $(GO_SRCS) - GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -o $@ . + GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=$(CGO_ENABLED) go build $(BUILD_FLAGS) -o $@ main.go bin/sha256sums.txt: $(bins) sha256sum -b $(bins) | sed 's|bin/||' > $@ diff --git a/cmd/bootloose/version.go b/cmd/bootloose/version.go index 3390f3c..15dec3c 100644 --- a/cmd/bootloose/version.go +++ b/cmd/bootloose/version.go @@ -7,7 +7,6 @@ package bootloose import ( "fmt" - _ "github.com/carlmjohnson/versioninfo" // Needed to set version info during go install "github.com/k0sproject/bootloose/version" "github.com/spf13/cobra" diff --git a/main.go b/main.go index 128a208..a34119a 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "github.com/k0sproject/bootloose/cmd/bootloose" + _ "github.com/carlmjohnson/versioninfo" // Ensure version info is added to binary + log "github.com/sirupsen/logrus" )