Forked from rvegas/Install protobuf 3.3 on Ubuntu 16.04
Last active
July 20, 2020 18:27
-
-
Save sofianinho/9a78beff3d6fa04b0a2095fd49beb899 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PROTOC_REPO="google/protobuf" | |
# Credits to: lukechilds here: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c | |
get_latest_release() { | |
URL="https://api.github.com/repos/$1/releases/latest" | |
VERSION=$(curl -L --silent $URL |grep '"tag_name":' |sed -E 's/.*"([^"]+)".*/\1/') | |
echo $VERSION | |
} | |
LATEST_VERSION=$(get_latest_release ${PROTOC_REPO}) | |
echo "Latest version is: ${LATEST_VERSION}" | |
_VERSION=${LATEST_VERSION:1} | |
# grab the latest version | |
curl -OL https://github.com/${PROTOC_REPO}/releases/download/${LATEST_VERSION}/protoc-${_VERSION}-linux-x86_64.zip | |
# Unzip | |
unzip protoc-${_VERSION}-linux-x86_64.zip -d protoc3 | |
# Move protoc to /usr/local/bin/ | |
sudo mv protoc3/bin/* /usr/local/bin/ | |
# Move protoc3/include to /usr/local/include/ | |
sudo mv protoc3/include/* /usr/local/include/ | |
# Optional: change owner | |
sudo chown $USER /usr/local/bin/protoc | |
sudo chown -R $USER /usr/local/include/google | |
exit 0 |
Just made the change, thanks it makes sense
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can replace
VERSION=$(curl --silent $URL |grep '"tag_name":' |sed -E 's/.*"([^"]+)".*/\1/')
withVERSION=$(curl -L --silent $URL |grep '"tag_name":' |sed -E 's/.*"([^"]+)".*/\1/')
so that curl follows redirects and works with the latest Github API changes.