From 3102383234f587ef3ecbaff365a9b56c302c01ec Mon Sep 17 00:00:00 2001 From: Eryu Xia Date: Fri, 18 Feb 2022 11:40:04 -0800 Subject: [PATCH] Add Github Actions (workflows) for building grpc-web protoc plugins. (#1203) --- .github/workflows/make-plugin-linux.yml | 32 +++++++++++++ .github/workflows/make-plugin-mac-os.yml | 48 +++++++++++++++++++ .github/workflows/make-plugin-windows.yml | 37 ++++++++++++++ .../gateway/docker/protoc_plugin/Dockerfile | 6 ++- 4 files changed, 122 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/make-plugin-linux.yml create mode 100644 .github/workflows/make-plugin-mac-os.yml create mode 100644 .github/workflows/make-plugin-windows.yml diff --git a/.github/workflows/make-plugin-linux.yml b/.github/workflows/make-plugin-linux.yml new file mode 100644 index 0000000..99cd53a --- /dev/null +++ b/.github/workflows/make-plugin-linux.yml @@ -0,0 +1,32 @@ +name: Make Linux Plugin + +on: + workflow_dispatch: + inputs: + version_number: + description: 'Version number' + required: true + default: '1.x.x' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build plugin docker image + run: docker-compose build prereqs protoc-plugin + - name: Copy binary from Docker image + run: | + docker cp $(docker create grpcweb/protoc-plugin):/github/grpc-web/javascript/net/grpc/web/generator/protoc-gen-grpc-web \ + ./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64 + - name: gen sha256 + run: | + openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256 \ + protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64 + - name: verify sha256 + run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256 + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: plugin + path: protoc-gen-grpc-web* diff --git a/.github/workflows/make-plugin-mac-os.yml b/.github/workflows/make-plugin-mac-os.yml new file mode 100644 index 0000000..442e52c --- /dev/null +++ b/.github/workflows/make-plugin-mac-os.yml @@ -0,0 +1,48 @@ +name: Make MacOS Plugin + +on: + workflow_dispatch: + inputs: + version_number: + description: 'Version number' + required: true + default: '1.x.x' + +jobs: + build: + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Install build utils + run: brew install coreutils automake + - name: Checkout protobuf code + run: | + ./scripts/init_submodules.sh + # Protobuf build instructions from: + # https://github.com/protocolbuffers/protobuf/blob/master/src/README.md + - name: Build protobuf (configure & make) + run: | + cd ./third_party/protobuf + ./autogen.sh + ./configure + make -j$(nproc) + make install + - name: Remove dynamite dependencies (similar to `-static` on linux) + run: rm /usr/local/lib/libproto*.dylib + - name: make + run: make clean && make plugin + - name: move + run: | + mv javascript/net/grpc/web/generator/protoc-gen-grpc-web \ + ./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64 + - name: gen sha256 + run: | + openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64.sha256 \ + protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64 + - name: verify sha256 + run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64.sha256 + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: plugin + path: protoc-gen-grpc-web* diff --git a/.github/workflows/make-plugin-windows.yml b/.github/workflows/make-plugin-windows.yml new file mode 100644 index 0000000..067aded --- /dev/null +++ b/.github/workflows/make-plugin-windows.yml @@ -0,0 +1,37 @@ +name: Make Windows Plugin + +on: + workflow_dispatch: + inputs: + version_number: + description: 'Version number' + required: true + default: '1.x.x' + +jobs: + build: + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - name: Print Bazel version + run: | + bazel version + - name: build + run: bazel build javascript/net/grpc/web/generator:protoc-gen-grpc-web + - name: move + run: | + mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web.exe \ + ./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-windows-x86_64.exe + shell: bash + - name: gen sha256 + run: | + openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-windows-x86_64.exe.sha256 \ + protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-windows-x86_64.exe + shell: bash + # TODO: Check sha256 (sha256sum not available for now. ) + #- name: verify sha256 + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: plugin + path: protoc-gen-grpc-web* diff --git a/net/grpc/gateway/docker/protoc_plugin/Dockerfile b/net/grpc/gateway/docker/protoc_plugin/Dockerfile index 69ba677..cd0bbd7 100644 --- a/net/grpc/gateway/docker/protoc_plugin/Dockerfile +++ b/net/grpc/gateway/docker/protoc_plugin/Dockerfile @@ -30,7 +30,11 @@ RUN apt-get -qq update && apt-get -qq install -y \ WORKDIR /github/grpc-web RUN cd ./third_party/protobuf && \ - ./autogen.sh && ./configure && make && make install && ldconfig + ./autogen.sh && \ + ./configure && \ + make && \ + make install && \ + ldconfig RUN cd ./javascript/net/grpc/web/generator && \ make protoc-gen-grpc-web