forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprotobuf_codegen.sh
More file actions
executable file
·54 lines (43 loc) · 1.41 KB
/
protobuf_codegen.sh
File metadata and controls
executable file
·54 lines (43 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -euo pipefail
if ! [[ "$0" =~ scripts/protobuf_codegen.sh ]]; then
echo "must be run from repository root"
exit 255
fi
# the versions here should match those of the binaries installed in the nix dev shell
## ensure the correct version of "buf" is installed
BUF_VERSION='1.47.2'
if [[ $(buf --version | cut -f2 -d' ') != "${BUF_VERSION}" ]]; then
echo "could not find buf ${BUF_VERSION}, is it installed + in PATH?"
exit 255
fi
## ensure the correct version of "protoc-gen-go" is installed
PROTOC_GEN_GO_VERSION='v1.35.1'
if [[ $(protoc-gen-go --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_VERSION}" ]]; then
echo "could not find protoc-gen-go ${PROTOC_GEN_GO_VERSION}, is it installed + in PATH?"
exit 255
fi
## ensure the correct version of "protoc-gen-go-grpc" is installed
PROTOC_GEN_GO_GRPC_VERSION='1.3.0'
if [[ $(protoc-gen-go-grpc --version | cut -f2 -d' ') != "${PROTOC_GEN_GO_GRPC_VERSION}" ]]; then
echo "could not find protoc-gen-go-grpc ${PROTOC_GEN_GO_GRPC_VERSION}, is it installed + in PATH?"
exit 255
fi
TARGET=$PWD/proto
if [ -n "${1:-}" ]; then
TARGET="$1"
fi
# move to api directory
cd "$TARGET"
echo "Running protobuf fmt..."
buf format -w
echo "Running protobuf lint check..."
if ! buf lint; then
echo "ERROR: protobuf linter failed"
exit 1
fi
echo "Re-generating protobuf..."
if ! buf generate; then
echo "ERROR: protobuf generation failed"
exit 1
fi