Skip to content

Commit c728536

Browse files
committed
Update Makefile to check the go version
1 parent 74b08fc commit c728536

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Makefile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ GOINSTALL ?= $(GOCMD) install
66
GOTEST ?= $(GOCMD) test
77
GOFMT ?= gofmt -w
88
GOCOVER ?= $(GOTEST) -covermode=count -v
9-
GOVERSIONMAJOR = $(shell go version | grep -o '[1-9].[0-9]' | cut -d '.' -f1)
10-
GOVERSIONMINOR = $(shell go version | grep -o '[1-9].[0-9]' | cut -d '.' -f2)
11-
VERSION_GE_1_5 = $(shell [ $(GOVERSIONMAJOR) -gt 1 -o $(GOVERSIONMINOR) -ge 5 ] && echo true)
129

1310
FPM_VERSION ?= $(shell ./dist/scw-Darwin-i386 --version | sed 's/.*v\([0-9.]*\),.*/\1/g')
1411
FPM_DOCKER ?= \
@@ -31,14 +28,17 @@ SRC = cmd/scw
3128
PACKAGES = pkg/api pkg/commands pkg/utils pkg/cli pkg/sshcommand pkg/config pkg/scwversion pkg/pricing
3229
REV = $(shell git rev-parse HEAD || echo "nogit")
3330
TAG = $(shell git describe --tags --always || echo "nogit")
34-
BUILDER = scaleway-cli-builder
35-
ALL_GO_FILES = $(shell find . -type f -name "*.go")
36-
ifeq ($(VERSION_GE_1_5),true)
3731
LDFLAGS = "-X github.com/scaleway/scaleway-cli/pkg/scwversion.GITCOMMIT=$(REV) \
3832
-X github.com/scaleway/scaleway-cli/pkg/scwversion.VERSION=$(TAG)"
39-
else
40-
LDFLAGS = "-X github.com/scaleway/scaleway-cli/pkg/scwversion.GITCOMMIT $(REV) \
41-
-X github.com/scaleway/scaleway-cli/pkg/scwversion.VERSION $(TAG)"
33+
BUILDER = scaleway-cli-builder
34+
ALL_GO_FILES = $(shell find . -type f -name "*.go")
35+
36+
# Check go version
37+
GOVERSIONMAJOR = $(shell go version | grep -o '[1-9].[0-9]' | cut -d '.' -f1)
38+
GOVERSIONMINOR = $(shell go version | grep -o '[1-9].[0-9]' | cut -d '.' -f2)
39+
VERSION_GE_1_5 = $(shell [ $(GOVERSIONMAJOR) -gt 1 -o $(GOVERSIONMINOR) -ge 5 ] && echo true)
40+
ifneq ($(VERSION_GE_1_5),true)
41+
$(error Bad go version, please install a version greater than or equal to 1.5)
4242
endif
4343

4444
BUILD_LIST = $(foreach int, $(SRC), $(int)_build)
@@ -73,7 +73,7 @@ $(CLEAN_LIST): %_clean:
7373
$(GOCLEAN) ./$*
7474
$(INSTALL_LIST): %_install:
7575
$(GOINSTALL) ./$*
76-
$(IREF_LIST): %_iref: pkg/scwversion/version.go
76+
$(IREF_LIST): %_iref:
7777
$(GOTEST) -ldflags $(LDFLAGS) -i ./$*
7878
$(TEST_LIST): %_test:
7979
$(GOTEST) -ldflags $(LDFLAGS) -v ./$*

0 commit comments

Comments
 (0)