Skip to content

Commit

Permalink
tools/golangci-lint: back to the binary, upgraded to 1.50.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fsouza committed Nov 7, 2022
1 parent 83988ef commit bd1dadd
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions tools/golangci-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ BUILD_ROOT="${REPO_ROOT}/build"
BUILD_BIN="${BUILD_ROOT}/bin"

NAME=golangci-lint
RELEASE=v1.47.3
RELEASE_BINARY="${BUILD_BIN}/${NAME}"
RELEASE=v1.50.1
OSX_RELEASE_256=0f615fb8c364f6e4a213f2ed2ff7aa1fc2b208addf29511e89c03534067bbf57
LINUX_RELEASE_256=4ba1dc9dbdf05b7bdc6f0e04bdfe6f63aa70576f51817be1b2540bbce017b69a

ARCH=amd64

RELEASE_BINARY="${BUILD_BIN}/${NAME}-${RELEASE}"

main() {
cd "${REPO_ROOT}/backend"
Expand All @@ -21,7 +26,31 @@ ensure_binary() {
echo "info: Downloading ${NAME} ${RELEASE} to build environment"

mkdir -p "${BUILD_BIN}"
env GOBIN="${BUILD_BIN}" go install github.com/golangci/golangci-lint/cmd/golangci-lint@"${RELEASE}"

case "${OSTYPE}" in
"darwin"*) os_type="darwin"; sum="${OSX_RELEASE_256}" ;;
"linux"*) os_type="linux"; sum="${LINUX_RELEASE_256}" ;;
*) echo "error: Unsupported OS '${OSTYPE}' for shellcheck install, please install manually" && exit 1 ;;
esac

release_archive="/tmp/${NAME}-${RELEASE}.tar.gz"

URL="https://github.com/golangci/golangci-lint/releases/download/${RELEASE}/golangci-lint-${RELEASE:1}-${os_type}-${ARCH}.tar.gz"
curl -sSL -o "${release_archive}" "${URL}"
echo ${sum} ${release_archive} | sha256sum --check --quiet -

release_tmp_dir="/tmp/${NAME}-${RELEASE}"
mkdir -p "${release_tmp_dir}"
tar -xzf "${release_archive}" --strip=1 -C "${release_tmp_dir}"

if [[ ! -f "${RELEASE_BINARY}" ]]; then
find "${BUILD_BIN}" -maxdepth 0 -regex '.*/'${NAME}'-[A-Za-z0-9\.]+$' -exec rm {} \; # cleanup older versions
mv "${release_tmp_dir}/${NAME}" "${RELEASE_BINARY}"
fi

# Cleanup stale resources.
rm "${release_archive}"
rm -rf "${release_tmp_dir}"
fi
}

Expand Down

0 comments on commit bd1dadd

Please sign in to comment.