github.com/whoyao/protocol@v0.0.0-20230519045905-2d8ace718ca5/bootstrap.sh (about)

     1  #!/bin/bash
     2  
     3  if ! command -v protoc &> /dev/null
     4  then
     5    echo "protoc is required and not found. please install"
     6    exit 1
     7  fi
     8  
     9  if ! command -v mage &> /dev/null
    10  then
    11    pushd /tmp
    12    git clone https://github.com/magefile/mage
    13    cd mage
    14    go run bootstrap.go
    15    rm -rf /tmp/mage
    16    popd
    17  fi
    18  
    19  if ! command -v mage &> /dev/null
    20  then
    21    echo "Ensure `go env GOPATH`/bin is in your \$PATH"
    22    exit 1
    23  fi
    24  
    25  go mod download
    26  
    27  GO_VERSION=`go version | { read _ _ v _; echo ${v#go}; }`
    28  GO_TARGET_VERSION=1.17
    29  
    30  function version { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; }
    31  
    32  if [ $(version $GO_VERSION) -ge $(version $GO_TARGET_VERSION) ];
    33    then
    34      go install github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
    35      go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
    36      go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
    37      go install github.com/livekit/psrpc/protoc-gen-psrpc@v0.3.0
    38    else
    39      go get -u github.com/twitchtv/twirp/protoc-gen-twirp@v8.1.3
    40      go get -u google.golang.org/protobuf/cmd/protoc-gen-go@v1.30.0
    41      go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
    42      go get -u github.com/livekit/psrpc/protoc-gen-psrpc@v0.3.0
    43  fi