Skip to content

Commit

Permalink
feat: Adding scripts for ts-proto, python_betterproto, and grpc-java …
Browse files Browse the repository at this point in the history
…plugins (#12)

Co-authored-by: Patrik <[email protected]>
  • Loading branch information
shaunco and zepatrik authored Dec 31, 2020
1 parent ecfc334 commit 45e5411
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: ory/build-buf-action@v0
with:
bufVersion: v0.31.1
protocPlugins: [email protected] [email protected]
protocPlugins: [email protected] [email protected] [email protected] [email protected] [email protected]
bufArgs: generate --config buf/api/buf.yaml --template buf/api/buf.gen.yaml
# Don't forget to commit and push after this step
```
Expand All @@ -38,5 +38,8 @@ Currently, the following plugins are available in the action:

- [go](https://github.com/protocolbuffers/protobuf-go)
- [go-grpc](https://github.com/grpc/grpc-go)
- [python_betterproto](https://github.com/danielgtaylor/python-betterproto)
- [ts-proto](https://github.com/stephenh/ts-proto)
- [grpc-java](https://github.com/grpc/grpc-java)

Please open a PR to add install scripts for any missing plugin.
22 changes: 22 additions & 0 deletions scripts/install-grpc-java-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail

source scripts/executor-info.sh

PLUGIN_VERSION=$1
BIN_DIR=$(pwd)/.bin
PLUGIN=protoc-gen-grpc-java
VER_FILE=$BIN_DIR/$PLUGIN.ver
PLUGIN_EXE=$BIN_DIR/$PLUGIN

# Can't use grep with `set -e pipfail`...
CUR_VER=
if [ -f "$VER_FILE" ]; then CUR_VER=($(<$VER_FILE)); fi

if [ ! -f "$PLUGIN_EXE" ] || ! [[ " ${CUR_VER[@]} " =~ " ${PLUGIN_VERSION} " ]]; then
echo "Installing $PLUGIN $PLUGIN_VERSION for OS $UNAME_OS Arch $UNAME_ARCH"
mkdir -p $BIN_DIR
curl --fail -sSL "https://repo1.maven.org/maven2/io/grpc/protoc-gen-grpc-java/$PLUGIN_VERSION/protoc-gen-grpc-java-$PLUGIN_VERSION-$NORMALIZED_OS-$UNAME_ARCH.exe" -o ./.bin/protoc-gen-grpc-java
chmod +x $PLUGIN_EXE
echo "$PLUGIN_VERSION" > $VER_FILE
fi
23 changes: 23 additions & 0 deletions scripts/install-python_betterproto-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail

source scripts/executor-info.sh

PLUGIN_VERSION=$1
BIN_DIR=$(pwd)/.bin
PLUGIN=protoc-gen-python_betterproto

VER_FILE=$BIN_DIR/$PLUGIN.ver
PLUGIN_EXE=$BIN_DIR/$PLUGIN

# Can't use grep with `set -e pipfail`...
CUR_VER=
if [ -f "$VER_FILE" ]; then CUR_VER=($(<$VER_FILE)); fi

if [ ! -f "$PLUGIN_EXE" ] || ! [[ " ${CUR_VER[@]} " =~ " ${PLUGIN_VERSION} " ]]; then
echo "Installing $PLUGIN $PLUGIN_VERSION"
mkdir -p $BIN_DIR
pip install --upgrade --target="$BIN_DIR" "betterproto[compiler]==$PLUGIN_VERSION"
echo "$PLUGIN_VERSION" > $VER_FILE
mv $BIN_DIR/bin/protoc* $BIN_DIR
fi
22 changes: 22 additions & 0 deletions scripts/install-ts-proto-plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
set -euo pipefail

source scripts/executor-info.sh

PLUGIN_VERSION=$1
BIN_DIR=$(pwd)/.bin
PLUGIN=protoc-gen-ts-proto
VER_FILE=$BIN_DIR/$PLUGIN.ver
PLUGIN_EXE=$BIN_DIR/$PLUGIN

# Can't use grep with `set -e pipfail`...
CUR_VER=
if [ -f "$VER_FILE" ]; then CUR_VER=($(<$VER_FILE)); fi

if [ ! -f "$PLUGIN_EXE" ] || ! [[ " ${CUR_VER[@]} " =~ " ${PLUGIN_VERSION} " ]]; then
echo "Installing $PLUGIN $PLUGIN_VERSION"
mkdir -p $BIN_DIR
npm install --prefix $BIN_DIR ts-proto@$PLUGIN_VERSION
echo "$PLUGIN_VERSION" > $VER_FILE
ln -s $BIN_DIR/node_modules/ts-proto/protoc-gen-ts_proto $BIN_DIR/protoc-gen-ts_proto
fi

0 comments on commit 45e5411

Please sign in to comment.