Merge pull request #17047 from iiamabby/protoc-install

Adding automated install of Protoc if not found on the system
This commit is contained in:
Benjamin Wang 2023-12-11 12:31:02 +00:00 committed by GitHub
commit c5a3479b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,8 +25,28 @@ fi
source ./scripts/test_lib.sh
if [[ $(protoc --version | cut -f2 -d' ') != "3.20.3" ]]; then
echo "could not find protoc 3.20.3, is it installed + in PATH?"
exit 255
echo "Could not find protoc 3.20.3, installing now..."
arch=$(go env GOARCH)
case ${arch} in
"amd64") file="x86_64" ;;
"arm64") file="aarch_64" ;;
*)
echo "Unsupported architecture: ${arch}"
exit 255
;;
esac
download_url="https://github.com/protocolbuffers/protobuf/releases/download/v3.20.3/protoc-3.20.3-linux-${file}.zip"
echo "Running on ${arch}."
wget ${download_url} && unzip -p protoc-3.20.3-linux-${file}.zip bin/protoc > tmpFile && mv tmpFile bin/protoc
rm protoc-3.20.3-linux-${file}.zip
chmod +x bin/protoc
PATH=$PATH:$(pwd)/bin
export PATH
echo "Now running: $(protoc --version)"
fi
GOFAST_BIN=$(tool_get_bin github.com/gogo/protobuf/protoc-gen-gofast)