dev: update install.sh (#672)

This commit is contained in:
Isaev Denis 2019-09-10 11:09:39 +03:00 committed by GitHub
parent 95d5b2c071
commit c87c37210f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 66 deletions

View File

@ -79,7 +79,7 @@ tools/go.mod:
tools/godownloader: Makefile tools/go.mod tools/godownloader: Makefile tools/go.mod
# https://github.com/goreleaser/godownloader/issues/133 # https://github.com/goreleaser/godownloader/issues/133
cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get github.com/goreleaser/godownloader cd tools && GOBIN=$(CURDIR)/tools GO111MODULE=off go get -u github.com/goreleaser/godownloader
tools/svg-term: tools/svg-term:
@mkdir -p tools @mkdir -p tools
@ -93,10 +93,8 @@ tools/Dracula.itermcolors:
docs/demo.svg: tools/svg-term tools/Dracula.itermcolors docs/demo.svg: tools/svg-term tools/Dracula.itermcolors
PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2 PATH=$(CURDIR)/tools:$${PATH} svg-term --cast=183662 --out docs/demo.svg --window --width 110 --height 30 --from 2000 --to 20000 --profile ./tools/Dracula.itermcolors --term iterm2
install.sh: install.sh: tools/godownloader .goreleaser.yml
# dependencies: tools/godownloader .goreleaser.yml PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
# TODO: use when Windows installation will be fixed in the upstream
#PATH=$(CURDIR)/tools:$${PATH} tools/godownloader .goreleaser.yml | sed '/DO NOT EDIT/s/ on [0-9TZ:-]*//' > $@
README.md: FORCE golangci-lint README.md: FORCE golangci-lint
go run ./scripts/gen_readme/main.go go run ./scripts/gen_readme/main.go

View File

@ -56,21 +56,6 @@ Latest version: ![GitHub release](https://img.shields.io/github/release/golangci
Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version): Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):
```bash
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z
# or install it into ./bin/
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
# In alpine linux (as it does not come with curl by default)
wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
golangci-lint --version
```
As a fallback you can also use `raw.githubusercontent.com`
```bash ```bash
# binary will be $(go env GOPATH)/bin/golangci-lint # binary will be $(go env GOPATH)/bin/golangci-lint
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z

View File

@ -56,21 +56,6 @@ Latest version: ![GitHub release](https://img.shields.io/github/release/golangci
Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version): Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):
```bash
# binary will be $(go env GOPATH)/bin/golangci-lint
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z
# or install it into ./bin/
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
# In alpine linux (as it does not come with curl by default)
wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z
golangci-lint --version
```
As a fallback you can also use `raw.githubusercontent.com`
```bash ```bash
# binary will be $(go env GOPATH)/bin/golangci-lint # binary will be $(go env GOPATH)/bin/golangci-lint
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z

View File

@ -27,11 +27,12 @@ parse_args() {
# over-ridden by flag below # over-ridden by flag below
BINDIR=${BINDIR:-./bin} BINDIR=${BINDIR:-./bin}
while getopts "b:dh?" arg; do while getopts "b:dh?x" arg; do
case "$arg" in case "$arg" in
b) BINDIR="$OPTARG" ;; b) BINDIR="$OPTARG" ;;
d) log_set_priority 10 ;; d) log_set_priority 10 ;;
h | \?) usage "$0" ;; h | \?) usage "$0" ;;
x) set -x ;;
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
@ -42,7 +43,7 @@ parse_args() {
# network, either nothing will happen or will syntax error # network, either nothing will happen or will syntax error
# out preventing half-done work # out preventing half-done work
execute() { execute() {
tmpdir=$(mktmpdir) tmpdir=$(mktemp -d)
log_debug "downloading files into ${tmpdir}" log_debug "downloading files into ${tmpdir}"
http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}" http_download "${tmpdir}/${TARBALL}" "${TARBALL_URL}"
http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}" http_download "${tmpdir}/${CHECKSUM}" "${CHECKSUM_URL}"
@ -50,36 +51,43 @@ execute() {
srcdir="${tmpdir}/${NAME}" srcdir="${tmpdir}/${NAME}"
rm -rf "${srcdir}" rm -rf "${srcdir}"
(cd "${tmpdir}" && untar "${TARBALL}") (cd "${tmpdir}" && untar "${TARBALL}")
install -d "${BINDIR}" test ! -d "${BINDIR}" && install -d "${BINDIR}"
for binexe in "golangci-lint" ; do for binexe in $BINARIES; do
if [ "$OS" = "windows" ]; then if [ "$OS" = "windows" ]; then
binexe="${binexe}.exe" binexe="${binexe}.exe"
fi fi
install "${srcdir}/${binexe}" "${BINDIR}/" install "${srcdir}/${binexe}" "${BINDIR}/"
log_info "installed ${BINDIR}/${binexe}" log_info "installed ${BINDIR}/${binexe}"
done done
rm -rf "${tmpdir}"
} }
is_supported_platform() { get_binaries() {
platform=$1 case "$PLATFORM" in
found=1 darwin/386) BINARIES="golangci-lint" ;;
case "$platform" in darwin/amd64) BINARIES="golangci-lint" ;;
darwin/amd64) found=0 ;; darwin/arm64) BINARIES="golangci-lint" ;;
darwin/386) found=0 ;; darwin/armv6) BINARIES="golangci-lint" ;;
windows/amd64) found=0 ;; darwin/armv7) BINARIES="golangci-lint" ;;
windows/386) found=0 ;; freebsd/386) BINARIES="golangci-lint" ;;
linux/amd64) found=0 ;; freebsd/amd64) BINARIES="golangci-lint" ;;
linux/386) found=0 ;; freebsd/arm64) BINARIES="golangci-lint" ;;
freebsd/armv6) BINARIES="golangci-lint" ;;
freebsd/armv7) BINARIES="golangci-lint" ;;
linux/386) BINARIES="golangci-lint" ;;
linux/amd64) BINARIES="golangci-lint" ;;
linux/arm64) BINARIES="golangci-lint" ;;
linux/armv6) BINARIES="golangci-lint" ;;
linux/armv7) BINARIES="golangci-lint" ;;
windows/386) BINARIES="golangci-lint" ;;
windows/amd64) BINARIES="golangci-lint" ;;
windows/arm64) BINARIES="golangci-lint" ;;
windows/armv6) BINARIES="golangci-lint" ;;
windows/armv7) BINARIES="golangci-lint" ;;
*)
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
exit 1
;;
esac esac
return $found
}
check_platform() {
if is_supported_platform "$PLATFORM"; then
# optional logging goes here
true
else
log_crit "platform $PLATFORM is not supported. Make sure this script is up-to-date and file request at https://github.com/${PREFIX}/issues/new"
exit 1
fi
} }
tag_to_version() { tag_to_version() {
if [ -z "${TAG}" ]; then if [ -z "${TAG}" ]; then
@ -172,8 +180,9 @@ log_crit() {
uname_os() { uname_os() {
os=$(uname -s | tr '[:upper:]' '[:lower:]') os=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$os" in case "$os" in
msys_nt*) os="windows" ;; cygwin_nt*) os="windows" ;;
mingw*) os="windows" ;; mingw*) os="windows" ;;
msys_nt*) os="windows" ;;
esac esac
echo "$os" echo "$os"
} }
@ -242,11 +251,6 @@ untar() {
;; ;;
esac esac
} }
mktmpdir() {
test -z "$TMPDIR" && TMPDIR="$(mktemp -d)"
mkdir -p "${TMPDIR}"
echo "${TMPDIR}"
}
http_download_curl() { http_download_curl() {
local_file=$1 local_file=$1
source_url=$2 source_url=$2
@ -367,7 +371,7 @@ uname_arch_check "$ARCH"
parse_args "$@" parse_args "$@"
check_platform get_binaries
tag_to_version tag_to_version