-
Notifications
You must be signed in to change notification settings - Fork 4.5k
scripts: improve regenerate.sh to use the correct proto compiler version #7064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
98b1c93
c9cbdcf
0185eb1
a309f73
61bb0b2
33534c3
1ff5e46
18505de
187a537
b4ba685
0da6723
c462adc
f6365fb
eb40292
5878795
77ac334
193e22c
8142941
ab458c5
222edaa
cee9875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/bin/bash | ||
# Copyright 2024 gRPC authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
# This script ensures the installation of protobuf on client machine. | ||
# In case of manual run of this script, make sure you pass the args | ||
# expected at | ||
# https://github.com/grpc/grpc-go/blob/master/scripts/install_protoc.sh#L60 | ||
|
||
set -eu -o pipefail | ||
|
||
source "$(dirname $0)/vet-common.sh" | ||
|
||
# The version of protoc that will be installed. | ||
PROTOC_VERSION="25.2" | ||
|
||
# Function to download pre-built binaries for Linux with | ||
# ARCH as $1, OS as $2, and INSTALL_PATH as $3 arguments. | ||
download_binary() { | ||
# Check if protoc is already available. | ||
if command -v protoc &> /dev/null; then | ||
if INSTALL_VERSION=$(protoc --version | cut -d' ' -f2 2>/dev/null); then | ||
if [ "$INSTALL_VERSION" = "$PROTOC_VERSION" ]; then | ||
echo "protoc version $PROTOC_VERSION is already installed." | ||
return | ||
else | ||
die "Existing protoc version ($INSTALL_VERSION) differs. Kindly make sure you have $PROTOC_VERSION installed." | ||
fi | ||
else | ||
arvindbr8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "Unable to determine installed protoc version. Starting the installation." | ||
fi | ||
fi | ||
DOWNLOAD_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-$2-$1.zip" | ||
# Download and unzip | ||
curl -LO "$DOWNLOAD_URL" | ||
INSTALL_DIR="${3:-${GOBIN:-${GOPATH:-$HOME/go}}}" | ||
unzip "protoc-${PROTOC_VERSION}-$2-$1.zip" -d $INSTALL_DIR | ||
rm "protoc-${PROTOC_VERSION}-$2-$1.zip" | ||
rm "${INSTALL_DIR}/readme.txt" | ||
} | ||
|
||
# Detect the architecture | ||
case "$(uname -m)" in | ||
"x86_64") ARCH="x86_64";; | ||
"aarch64") ARCH="aarch_64";; | ||
"arm64") ARCH="aarch_64";; | ||
*) die "Unsupported architecture. Please consider manual installation from \ | ||
https://github.com/protocolbuffers/protobuf/releases/ and add to PATH." | ||
esac | ||
|
||
# Detect the Operating System | ||
INSTALL_PATH=${1:+"$1"} | ||
case "$(uname -s)" in | ||
"Darwin") download_binary $ARCH "osx" "$INSTALL_PATH";; | ||
"Linux") download_binary $ARCH "linux" "$INSTALL_PATH";; | ||
*) die "Unsupported OS. Please consider manual installation from \ | ||
https://github.com/protocolbuffers/protobuf/releases/ and add to PATH" ;; | ||
esac |
arvindbr8 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,18 +20,11 @@ trap cleanup EXIT | |
# consistent with the place where all binaries installed by scripts in this repo | ||
# go.) | ||
if [[ "$1" = "-install" ]]; then | ||
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then | ||
PROTOBUF_VERSION=25.2 # Shows up in pb.go files as v4.22.0 | ||
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip | ||
pushd /home/runner/go | ||
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME} | ||
unzip ${PROTOC_FILENAME} | ||
protoc --version # Check that the binary works. | ||
popd | ||
else | ||
arvindbr8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# TODO: replace with install protoc when https://github.com/grpc/grpc-go/pull/7064 is merged. | ||
die "-install currently intended for use in CI only." | ||
fi | ||
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then | ||
source ./scripts/install_protoc.sh "/home/runner/go" | ||
else | ||
die "run protoc installer https://github.com/grpc/grpc-go/blob/master/scripts/install_protoc.sh" | ||
fi | ||
Comment on lines
+23
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: This still looks like a link to what to do. But just points to a script without the how to. Have you looked at my other comment that talked about why it might be nice to run install_protoc.sh also in this case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added few lines on how to use |
||
echo SUCCESS | ||
exit 0 | ||
elif [[ "$#" -ne 0 ]]; then | ||
|
Uh oh!
There was an error while loading. Please reload this page.