|
3 | 3 | # This script is intended to be a convenience, to be called from the
|
4 | 4 | # Makefile `.install.golangci-lint` target. Any other usage is not recommended.
|
5 | 5 |
|
6 |
| -die() { echo "${1:-No error message given} (from $(basename $0))"; exit 1; } |
| 6 | +die() { echo "${1:-No error message given} (from $(basename "$0"))"; exit 1; } |
7 | 7 |
|
8 | 8 | [ -n "$VERSION" ] || die "\$VERSION is empty or undefined"
|
9 | 9 |
|
| 10 | +# Strip the leading v, if found. |
| 11 | +VERSION=${VERSION#v} |
| 12 | + |
10 | 13 | function install() {
|
11 | 14 | local retry=$1
|
12 | 15 |
|
13 | 16 | local msg="Installing golangci-lint v$VERSION into $BIN"
|
14 | 17 | if [[ $retry -ne 0 ]]; then
|
15 | 18 | msg+=" - retry #$retry"
|
16 | 19 | fi
|
17 |
| - echo $msg |
| 20 | + echo "$msg" |
18 | 21 |
|
19 |
| - curl -sSL --retry 5 https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v$VERSION |
| 22 | + curl -sSfL --retry 5 https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $BINDIR "v$VERSION" |
20 | 23 | }
|
21 | 24 |
|
22 |
| -# Undocumented behavior: golangci-lint installer requires $BINDIR in env, |
23 |
| -# will default to ./bin but we can't rely on that. |
24 |
| -export BINDIR="./bin" |
| 25 | +BINDIR="./bin" |
25 | 26 | BIN="$BINDIR/golangci-lint"
|
26 |
| -if [ ! -x "$BIN" ]; then |
27 |
| - # This flakes much too frequently with "crit unable to find v1.51.1" |
28 |
| - for retry in $(seq 0 5); do |
29 |
| - install $retry && exit 0 |
30 |
| - sleep 5 |
31 |
| - done |
32 |
| -else |
33 |
| - # Prints its own file name as part of --version output |
34 |
| - $BIN --version | grep "$VERSION" |
35 |
| - if [ $? -eq 0 ]; then |
36 |
| - echo "Using existing $BINDIR/$($BIN --version)" |
37 |
| - else |
38 |
| - install |
39 |
| - fi |
| 27 | +if [ -x "$BIN" ] && $BIN --version | grep "$VERSION"; then |
| 28 | + echo "Using existing $BIN" |
| 29 | + exit 0 |
40 | 30 | fi
|
| 31 | + |
| 32 | +# This flakes much too frequently with "crit unable to find v1.51.1" |
| 33 | +for retry in $(seq 0 5); do |
| 34 | + install "$retry" && exit 0 |
| 35 | + sleep 5 |
| 36 | +done |
0 commit comments