Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Commit

Permalink
Merge pull request #518 from nirmoy/go_version_check1
Browse files Browse the repository at this point in the history
Makefile: Add go version check
  • Loading branch information
caaspjenkins authored Jul 25, 2019
2 parents 0de8752 + 63a0be4 commit 345d689
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ ifeq ($(GOMOD), off)
GOMODFLAG=
endif

#retrieve go version details for version check
GO_VERSION := $(shell $(GO) version | sed -e 's/^[^0-9.]*\([0-9.]*\).*/\1/')
GO_VERSION_MAJ := $(shell echo $(GO_VERSION) | cut -f1 -d'.')
GO_VERSION_MIN := $(shell echo $(GO_VERSION) | cut -f2 -d'.')

GOFMT ?= gofmt
TERRAFORM ?= $(shell which terraform 2>/dev/null || which true 2>/dev/null)
GO_MD2MAN ?= go-md2man
Expand All @@ -32,7 +37,7 @@ SKUBA_SRCS = $(shell find $(SKUBA_DIRS) -type f -name '*.go')
all: install

.PHONY: build
build:
build: go-version-check
$(GO) build $(GOMODFLAG) $(SKUBA_LDFLAGS) -tags $(TAGS) ./cmd/...

MANPAGES_MD := $(wildcard docs/man/*.md)
Expand All @@ -45,7 +50,7 @@ docs/man/%.1: docs/man/%.1.md
docs: $(MANPAGES)

.PHONY: install
install:
install: go-version-check
$(GO) install $(GOMODFLAG) $(SKUBA_LDFLAGS) -tags $(TAGS) ./cmd/...
$(RM) -f $(GOBINPATH)/kubectl-caasp
$(LN) -s $(GOBINPATH)/skuba $(GOBINPATH)/kubectl-caasp
Expand All @@ -67,6 +72,11 @@ staging:
release:
make TAGS=release install

.PHONY: go-version-check
go-version-check:
@[ $(GO_VERSION_MAJ) -ge 2 ] || \
[ $(GO_VERSION_MAJ) -eq 1 -a $(GO_VERSION_MIN) -ge 12 ] || (echo "FATAL: Go version should be >= 1.12.x" ; exit 1 ; )

.PHONY: lint
lint:
# explicitly enable GO111MODULE otherwise go mod will fail
Expand Down

0 comments on commit 345d689

Please sign in to comment.