Skip to content

Commit cf92c5f

Browse files
committed
Install protoc
1 parent c23c394 commit cf92c5f

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616

1717
steps:
1818
- uses: actions/checkout@v3
19+
- name: Install protoc
20+
run: script/install-protoc
1921
- name: Build
2022
run: cargo build
2123
- name: Run tests

script/install-protoc

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#! /usr/bin/env bash
2+
# Unconditionally install the exact version of protoc that we use,
3+
# overwriting whatever is installed in /usr/local/bin.
4+
#
5+
# We have a CI job that checks the generated code, looking for an exact match,
6+
# so it's important that everyone use the same version of protoc.
7+
8+
# Unofficial bash strict mode
9+
set -euo pipefail
10+
IFS=$'\n\t'
11+
12+
# Don't use sudo if we're root. Not every Docker image has sudo.
13+
SUDO=sudo
14+
if [[ $EUID == "0" ]]; then
15+
SUDO=
16+
fi
17+
18+
if ! type -P unzip >/dev/null; then
19+
echo "Installing unzip..."
20+
# This should only happen on Linux. MacOS ships with unzip.
21+
sudo apt-get install -y unzip
22+
fi
23+
24+
echo "Installing protoc..."
25+
26+
# Download protoc
27+
protoc_version="3.17.0"
28+
protoc_os="osx-x86_64"
29+
if [[ $OSTYPE == linux* ]]; then
30+
protoc_os="linux-x86_64"
31+
fi
32+
mkdir _tools
33+
cd _tools
34+
protoc_zip="protoc-$protoc_version-$protoc_os.zip"
35+
curl -OL "https://github.com/protocolbuffers/protobuf/releases/download/v$protoc_version/$protoc_zip"
36+
37+
# Install protoc to /usr/local
38+
prefix=/usr/local
39+
unzip -o $protoc_zip -d tmp
40+
$SUDO mkdir -p $prefix/bin
41+
$SUDO mv tmp/bin/protoc $prefix/bin/protoc
42+
$SUDO mkdir -p $prefix/include/google/protobuf
43+
$SUDO rm -rf $prefix/include/google/protobuf
44+
$SUDO mv tmp/include/google/protobuf $prefix/include/google/protobuf
45+
cd ..
46+
rm -rf _tools

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy