From 5e817641bb5256b80dab6928f45a65ba6b907786 Mon Sep 17 00:00:00 2001 From: Alessio Treglia Date: Thu, 26 Sep 2019 18:15:07 -0700 Subject: [PATCH] Merge PR #141: Upgrade golangci-lint to latest release (1.19.1) --- contrib/devtools/Makefile | 3 +-- contrib/devtools/install-golangci-lint.sh | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 2bd8b5c..293cb81 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -17,7 +17,6 @@ endif GOPATH ?= $(shell $(GO) env GOPATH) GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com -GOLANGCI_LINT_VERSION := v1.18.0 GOLANGCI_LINT_HASHSUM := 8d21cc95da8d3daf8321ac40091456fc26123c964d7c2281d339d431f2f4c840 ### @@ -54,7 +53,7 @@ tools-stamp: $(RUNSIM) $(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh @echo "Installing golangci-lint..." - @bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_HASHSUM) + @bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_HASHSUM) # Install the runsim binary with a temporary workaround of entering an outside # directory as the "go get" command ignores the -mod option and will polute the diff --git a/contrib/devtools/install-golangci-lint.sh b/contrib/devtools/install-golangci-lint.sh index b957138..427a2cf 100644 --- a/contrib/devtools/install-golangci-lint.sh +++ b/contrib/devtools/install-golangci-lint.sh @@ -2,19 +2,24 @@ set -euo pipefail +installer="$(mktemp)" +trap "rm -f ${installer}" EXIT + +GOBIN="${1}" +CURL="$(which curl)" +HASHSUM="${2}" + f_sha256() { local l_file l_file=$1 python -sBc "import hashlib;print(hashlib.sha256(open('$l_file','rb').read()).hexdigest())" } -installer="$(mktemp)" -trap "rm -f ${installer}" EXIT - -GOBIN="${1}" -VERSION="${2}" -HASHSUM="${3}" -CURL="$(which curl)" +get_latest_release() { + "${CURL}" --silent "https://api.github.com/repos/$1/releases/latest" | \ + grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' +} +VERSION="$(get_latest_release golangci/golangci-lint)" echo "Downloading golangci-lint ${VERSION} installer ..." >&2 "${CURL}" -sfL "https://raw.githubusercontent.com/golangci/golangci-lint/${VERSION}/install.sh" > "${installer}"