Skip to content

Commit

Permalink
make: check minimum go version when build
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Jun 3, 2021
1 parent 4337356 commit ee39ef9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ GIT_BRANCH=`git rev-parse --symbolic-full-name --abbrev-ref HEAD`
GIT_DIRTY=`git diff-index --quiet HEAD -- || echo "dirty-"`
VERSION=`git describe --always`
GO_VERSION=`go version | awk '{print $$3}'`
MINIMUM_GO_VERSION=1.16.2
BUILD_FLAGS="-X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
CI_BUILD_FLAGS="-w -extldflags "-static" -X main.gitCommit=${GIT_COMMIT} -X main.version=${VERSION} -X main.goVersion=${GO_VERSION} -X main.buildDate=${BUILD_DATE}"
LITMUS_URL_OLD="http://localhost:20080/remote.php/webdav"
Expand All @@ -29,7 +30,7 @@ off:
imports: off
`go env GOPATH`/bin/goimports -w tools pkg internal cmd

build: imports
build: imports testGoVersion
go build -ldflags ${BUILD_FLAGS} -o ./cmd/revad/revad ./cmd/revad
go build -ldflags ${BUILD_FLAGS} -o ./cmd/reva/reva ./cmd/reva

Expand Down Expand Up @@ -71,6 +72,9 @@ lint:
contrib:
git shortlog -se | cut -c8- | sort -u | awk '{print "-", $$0}' | grep -v 'users.noreply.github.com' > CONTRIBUTORS.md

testGoVersion:
echo -e "$(MINIMUM_GO_VERSION)\n$(shell echo $(GO_VERSION) | cut -c3-)" | sort -ct. -k1,1n -k2,2n -k3,3n &> /dev/null || echo -e "\n\033[33;5m[WARNING]\033[0m You are using a not supported go version. Please use $(MINIMUM_GO_VERSION) or above.\n"

# for manual building only
deps:
cd /tmp && rm -rf golangci-lint && git clone --quiet -b 'v1.38.0' --single-branch --depth 1 https://github.com/golangci/golangci-lint &> /dev/null && cd golangci-lint/cmd/golangci-lint && go install
Expand Down

0 comments on commit ee39ef9

Please sign in to comment.