github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/dist/build.sh (about) 1 #!/bin/sh -e 2 3 4 build() { 5 ROOT="$GOPATH/src/github.com/amarpal/go-tools" 6 7 os="$1" 8 arch="$2" 9 10 echo "Building GOOS=$os GOARCH=$arch..." 11 exe="staticcheck" 12 if [ $os = "windows" ]; then 13 exe="${exe}.exe" 14 fi 15 target="staticcheck_${os}_${arch}" 16 17 arm="" 18 case "$arch" in 19 armv5l) 20 arm=5 21 arch=arm 22 ;; 23 armv6l) 24 arm=6 25 arch=arm 26 ;; 27 armv7l) 28 arm=7 29 arch=arm 30 ;; 31 arm64) 32 arch=arm64 33 ;; 34 esac 35 36 mkdir "$d/staticcheck" 37 cp "$ROOT/LICENSE" "$ROOT/LICENSE-THIRD-PARTY" "$d/staticcheck" 38 CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm GO111MODULE=on go build -trimpath -o "$d/staticcheck/$exe" github.com/amarpal/go-tools/cmd/staticcheck 39 ( 40 cd "$d" 41 tar -czf "$target.tar.gz" staticcheck 42 sha256sum "$target.tar.gz" > "$target.tar.gz.sha256" 43 ) 44 rm -rf "$d/staticcheck" 45 } 46 47 rev="$1" 48 if [ -z "$rev" ]; then 49 echo "Usage: $0 <version>" 50 exit 1 51 fi 52 53 54 mkdir "$rev" 55 d=$(realpath "$rev") 56 57 wrk=$(mktemp -d) 58 trap "{ rm -rf \"$wrk\"; }" EXIT 59 cd "$wrk" 60 61 go mod init foo 62 GO111MODULE=on go get -d github.com/amarpal/go-tools/cmd/staticcheck@"$rev" 63 64 65 SYSTEMS=(windows linux freebsd) 66 ARCHS=(amd64 386) 67 for os in ${SYSTEMS[@]}; do 68 for arch in ${ARCHS[@]}; do 69 build "$os" "$arch" 70 done 71 done 72 73 build "darwin" "amd64" 74 build "darwin" "arm64" 75 76 for arch in armv5l armv6l armv7l arm64; do 77 build "linux" "$arch" 78 done 79 80 ( 81 cd "$d" 82 sha256sum -c --strict *.sha256 83 )