Skip to content

Commit ba14aec

Browse files
committed
Rework release workflows using Github runners (and remove Zig)
This PR modernizes the grpc-web release workflows by migrating from make/Zig-based build systems to Bazel across all platforms, and updates GitHub Actions to use current versions. Removes Zig build system and migrates all platforms to use Bazel for building the protoc plugin Standardizes version handling across workflows with dynamic computation from inputs or Git refs Updates GitHub Actions versions and adds support for ARM64 runners on all platforms
1 parent 56d857e commit ba14aec

10 files changed

Lines changed: 260 additions & 344 deletions

File tree

.bazelrc

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
build --copt=-Wno-error=deprecated-declarations --host_copt=-Wno-error=deprecated-declarations
1+
# Common build settings for unix-like systems
2+
build --copt=-Wno-error=deprecated-declarations
3+
build --host_copt=-Wno-error=deprecated-declarations
24

35
# Required until this is the default; expected in Bazel 7
46
common --enable_bzlmod
57

6-
# Load any settings specific to the current user.
7-
# .bazelrc.user should appear in .gitignore so that settings are not shared with team members
8-
# This needs to be last statement in this
9-
# config, as the user configuration should be able to overwrite flags from this file.
10-
# See https://docs.bazel.build/versions/master/best-practices.html#bazelrc
11-
# (Note that we use .bazelrc.user so the file appears next to .bazelrc in directory listing,
12-
# rather than user.bazelrc as suggested in the Bazel docs)
8+
# Per-user settings (gitignored). Keep last so local flags can override.
9+
# Docs: https://bazel.build/configure/best-practices#bazelrc
1310
try-import %workspace%/.bazelrc.user
14-

.bazelrc.windows

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This is a Windows-specific bazelrc file for use in GitHub Actions.
2+
# It contains settings from the main .bazelrc file that are relevant for Windows builds.
3+
4+
# Windows specific settings
5+
build --copt=-DABSL_HAVE_WORKING_GCC_WNO_DEPRECATED_DECLARATIONS=0
6+
build --host_copt=-DABSL_HAVE_WORKING_GCC_WNO_DEPRECATED_DECLARATIONS=0
7+
8+
# Required until this is the default; expected in Bazel 7
9+
common --enable_bzlmod
10+
11+
# Per-user settings (gitignored). Keep last so local flags can override.
12+
# Docs: https://bazel.build/configure/best-practices#bazelrc
13+
try-import %workspace%/.bazelrc.user

.github/workflows/make-plugin-arm.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.
Lines changed: 80 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,97 @@
11
name: Make Linux Plugin
22

33
on:
4+
push:
5+
paths:
6+
- .github/workflows/make-plugin-linux.yml
7+
pull_request:
8+
paths:
9+
- .github/workflows/make-plugin-linux.yml
410
workflow_dispatch:
511
inputs:
612
version_number:
713
description: 'Version number'
814
required: true
9-
default: '1.x.x'
15+
default: '2.x.x'
1016

1117
jobs:
1218
build:
13-
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [ubuntu-24.04, ubuntu-24.04-arm]
23+
runs-on: ${{ matrix.os }}
1424
steps:
15-
- uses: actions/checkout@v3
16-
- name: Build plugin docker image
17-
run: docker-compose build prereqs protoc-plugin
18-
- name: Copy binary from Docker image
25+
- uses: actions/checkout@v4
26+
- name: Compute VERSION_NUMBER
1927
run: |
20-
docker cp $(docker create grpcweb/protoc-plugin):/github/grpc-web/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
21-
./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64
22-
- name: gen sha256
28+
INPUT_VERSION="${{ github.event.inputs.version_number }}"
29+
if [ -n "$INPUT_VERSION" ]; then
30+
VERSION="$INPUT_VERSION"
31+
else
32+
VERSION="$GITHUB_REF_NAME"
33+
fi
34+
VERSION="${VERSION//\//-}"
35+
echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV"
36+
echo "Computed VERSION_NUMBER=$VERSION"
37+
- name: Compute ARCH suffix and artifact name
38+
id: meta
2339
run: |
24-
openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256 \
25-
protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64
26-
- name: verify sha256
27-
run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-linux-x86_64.sha256
40+
ARCH=$(uname -m)
41+
case "$ARCH" in
42+
aarch64|arm64)
43+
ARCH_SUFFIX="aarch64"
44+
;;
45+
x86_64|amd64)
46+
ARCH_SUFFIX="x86_64"
47+
;;
48+
*)
49+
echo "Unsupported architecture: $ARCH" >&2
50+
exit 1
51+
;;
52+
esac
53+
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-linux-${ARCH_SUFFIX}"
54+
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
55+
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
56+
echo "Will produce artifact: $ARTIFACT"
57+
- name: Install Bazelisk (Bazel)
58+
run: |
59+
sudo apt-get update
60+
sudo apt-get install -y unzip zip
61+
ARCH=$(uname -m)
62+
case "$ARCH" in
63+
aarch64|arm64)
64+
BAZELISK_URL="https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-arm64"
65+
;;
66+
x86_64|amd64)
67+
BAZELISK_URL="https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64"
68+
;;
69+
*)
70+
echo "Unsupported architecture for Bazelisk: $ARCH" >&2
71+
exit 1
72+
;;
73+
esac
74+
echo "Downloading Bazelisk from $BAZELISK_URL"
75+
sudo curl -L -o /usr/local/bin/bazelisk "$BAZELISK_URL"
76+
sudo chmod +x /usr/local/bin/bazelisk
77+
# Also provide `bazel` symlink for tools that expect it
78+
sudo ln -sf /usr/local/bin/bazelisk /usr/local/bin/bazel
79+
bazelisk version
80+
- name: Build protoc-gen-grpc-web with Bazel
81+
run: |
82+
bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web
83+
- name: Move artifact
84+
run: |
85+
mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
86+
./${ARTIFACT}
87+
- name: Generate sha256
88+
run: |
89+
openssl dgst -sha256 -r -out ${ARTIFACT}.sha256 \
90+
${ARTIFACT}
91+
- name: Verify sha256
92+
run: sha256sum -c ${ARTIFACT}.sha256
2893
- name: Upload artifacts
29-
uses: actions/upload-artifact@v3
94+
uses: actions/upload-artifact@v4
3095
with:
31-
name: plugin
96+
name: ${{ steps.meta.outputs.artifact }}
3297
path: protoc-gen-grpc-web*
Lines changed: 69 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,80 @@
1-
name: Make MacOS Plugin
1+
name: Make macOS Plugin
22

33
on:
4+
push:
5+
paths:
6+
- .github/workflows/make-plugin-mac-os.yml
7+
pull_request:
8+
paths:
9+
- .github/workflows/make-plugin-mac-os.yml
410
workflow_dispatch:
511
inputs:
612
version_number:
713
description: 'Version number'
814
required: true
9-
default: '1.x.x'
15+
default: '2.x.x'
1016

1117
jobs:
1218
build:
13-
runs-on: macos-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [macos-13, macos-14]
23+
runs-on: ${{ matrix.os }}
1424
steps:
15-
- uses: actions/checkout@v3
16-
- name: Install build utils
17-
run: brew install coreutils automake
18-
- name: Checkout protobuf code
19-
run: |
20-
./scripts/init_submodules.sh
21-
# Protobuf build instructions from:
22-
# https://github.com/protocolbuffers/protobuf/blob/master/src/README.md
23-
- name: Build protobuf (configure & make)
24-
run: |
25-
cd ./third_party/protobuf
26-
./autogen.sh
27-
./configure
28-
make -j$(nproc)
29-
make install
30-
- name: Remove dynamite dependencies (similar to `-static` on linux)
31-
run: rm /usr/local/lib/libproto*.dylib
32-
- name: make
33-
run: make clean && make plugin
34-
- name: move
35-
run: |
36-
mv javascript/net/grpc/web/generator/protoc-gen-grpc-web \
37-
./protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64
38-
- name: gen sha256
39-
run: |
40-
openssl dgst -sha256 -r -out protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64.sha256 \
41-
protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64
42-
- name: verify sha256
43-
run: sha256sum -c protoc-gen-grpc-web-${{ github.event.inputs.version_number }}-darwin-x86_64.sha256
44-
- name: Upload artifacts
45-
uses: actions/upload-artifact@v3
46-
with:
47-
name: plugin
48-
path: protoc-gen-grpc-web*
25+
- uses: actions/checkout@v4
26+
- name: Compute VERSION_NUMBER
27+
run: |
28+
INPUT_VERSION="${{ github.event.inputs.version_number }}"
29+
if [ -n "$INPUT_VERSION" ]; then
30+
VERSION="$INPUT_VERSION"
31+
else
32+
VERSION="$GITHUB_REF_NAME"
33+
fi
34+
# Minimal sanitization: replace slashes with dashes to keep filenames valid
35+
VERSION="${VERSION//\//-}"
36+
echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV"
37+
echo "Computed VERSION_NUMBER=$VERSION"
38+
- name: Compute ARCH suffix and artifact name
39+
id: meta
40+
run: |
41+
ARCH=$(uname -m)
42+
case "$ARCH" in
43+
arm64)
44+
ARCH_SUFFIX="aarch64"
45+
;;
46+
x86_64)
47+
ARCH_SUFFIX="x86_64"
48+
;;
49+
*)
50+
echo "Unsupported architecture: $ARCH" >&2
51+
exit 1
52+
;;
53+
esac
54+
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-darwin-${ARCH_SUFFIX}"
55+
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
56+
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
57+
echo "Will produce artifact: $ARTIFACT"
58+
- name: Install Bazelisk (Bazel)
59+
run: |
60+
brew update
61+
brew install bazelisk
62+
bazelisk version
63+
- name: Build protoc-gen-grpc-web with Bazel
64+
run: |
65+
bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web
66+
- name: Move artifact
67+
run: |
68+
mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
69+
./${ARTIFACT}
70+
- name: Generate sha256
71+
run: |
72+
openssl dgst -sha256 -r -out ${ARTIFACT}.sha256 \
73+
${ARTIFACT}
74+
- name: Verify sha256
75+
run: shasum -a 256 -c ${ARTIFACT}.sha256
76+
- name: Upload artifacts
77+
uses: actions/upload-artifact@v4
78+
with:
79+
name: ${{ steps.meta.outputs.artifact }}
80+
path: protoc-gen-grpc-web*

0 commit comments

Comments
 (0)