Skip to content

Commit f1a24c6

Browse files
committed
NICE :) - refactor(build): streamline Windows plugin workflow with architecture support and improved artifact handling
1 parent 26494b9 commit f1a24c6

File tree

4 files changed

+79
-74
lines changed

4 files changed

+79
-74
lines changed

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

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,36 +21,6 @@ jobs:
2121
- uses: actions/checkout@v3
2222
with:
2323
submodules: 'recursive'
24-
- name: Compute VERSION_NUMBER
24+
- name: Say goodbye :)
2525
run: |
26-
INPUT_VERSION="${{ github.event.inputs.version_number }}"
27-
if [ -n "$INPUT_VERSION" ]; then
28-
VERSION="$INPUT_VERSION"
29-
else
30-
VERSION="$GITHUB_REF_NAME"
31-
fi
32-
VERSION="${VERSION//\//-}"
33-
echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV"
34-
echo "Computed VERSION_NUMBER=$VERSION"
35-
- name: Setup Zig
36-
run: |
37-
mkdir -p $HOME/.local/bin $HOME/.local/zig
38-
curl -L 'https://ziglang.org/download/0.12.0/zig-linux-x86_64-0.12.0.tar.xz' | tar xJ --strip-components=1 --directory=$HOME/.local/zig
39-
ln -sf $HOME/.local/zig/zig $HOME/.local/bin/zig
40-
echo "PATH=$PATH:$HOME/.local/bin" >> $GITHUB_ENV
41-
- name: Build plugin
42-
run: |
43-
cd javascript/net/grpc/web/generator
44-
VERSION="$VERSION_NUMBER" zig build -Doptimize=ReleaseFast
45-
- name: gen and verify sha256
46-
run: |
47-
cd javascript/net/grpc/web/generator/zig-out/bin
48-
for exe in $(ls); do
49-
openssl dgst -sha256 -r -out "${exe}.sha256" "$exe"
50-
sha256sum -c "${exe}.sha256"
51-
done
52-
- name: Upload artifacts
53-
uses: actions/upload-artifact@v4
54-
with:
55-
name: plugin
56-
path: javascript/net/grpc/web/generator/zig-out/bin/
26+
echo "hi, i think i'm retired :)"

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ jobs:
5252
esac
5353
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-linux-${ARCH_SUFFIX}"
5454
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
55-
echo "arch_suffix=$ARCH_SUFFIX" >> "$GITHUB_OUTPUT"
5655
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
5756
echo "Will produce artifact: $ARTIFACT"
5857
- name: Install Bazelisk (Bazel)
@@ -77,8 +76,7 @@ jobs:
7776
sudo chmod +x /usr/local/bin/bazelisk
7877
# Also provide `bazel` symlink for tools that expect it
7978
sudo ln -sf /usr/local/bin/bazelisk /usr/local/bin/bazel
80-
- name: Print Bazel version
81-
run: bazelisk version
79+
bazelisk version
8280
- name: Build protoc-gen-grpc-web with Bazel
8381
run: |
8482
bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web

.github/workflows/make-plugin-mac-os.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ jobs:
5353
esac
5454
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-darwin-${ARCH_SUFFIX}"
5555
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
56-
echo "arch_suffix=$ARCH_SUFFIX" >> "$GITHUB_OUTPUT"
5756
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
5857
echo "Will produce artifact: $ARTIFACT"
5958
- name: Install Bazelisk (Bazel)
6059
run: |
6160
brew update
6261
brew install bazelisk coreutils
63-
- name: Print Bazel version
64-
run: bazelisk version
62+
bazelisk version
6563
- name: Build protoc-gen-grpc-web with Bazel
6664
run: |
6765
bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web

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

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -16,40 +16,79 @@ on:
1616

1717
jobs:
1818
build:
19-
runs-on: windows-2025
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
os: [windows-2025, windows-11-arm]
23+
runs-on: ${{ matrix.os }}
2024
steps:
21-
- uses: actions/checkout@v3
22-
- name: Compute VERSION_NUMBER
23-
run: |
24-
INPUT_VERSION="${{ github.event.inputs.version_number }}"
25-
if [ -n "$INPUT_VERSION" ]; then
26-
VERSION="$INPUT_VERSION"
27-
else
28-
VERSION="$GITHUB_REF_NAME"
29-
fi
30-
VERSION="${VERSION//\//-}"
31-
echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV"
32-
echo "Computed VERSION_NUMBER=$VERSION"
33-
shell: bash
34-
- name: Print Bazel version
35-
run: |
36-
bazel version
37-
- name: build
38-
run: bazel --noworkspace_rc --bazelrc=.bazelrc.windows build javascript/net/grpc/web/generator:protoc-gen-grpc-web
39-
- name: move
40-
run: |
41-
mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web.exe \
42-
./protoc-gen-grpc-web-${VERSION_NUMBER}-windows-x86_64.exe
43-
shell: bash
44-
- name: gen sha256
45-
run: |
46-
openssl dgst -sha256 -r -out protoc-gen-grpc-web-${VERSION_NUMBER}-windows-x86_64.exe.sha256 \
47-
protoc-gen-grpc-web-${VERSION_NUMBER}-windows-x86_64.exe
48-
shell: bash
49-
# TODO: Check sha256 (sha256sum not available for now. )
50-
#- name: verify sha256
51-
- name: Upload artifacts
52-
uses: actions/upload-artifact@v4
53-
with:
54-
name: plugin
55-
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+
shell: bash
39+
- name: Compute ARCH suffix and artifact name
40+
id: meta
41+
run: |
42+
ARCH=$(uname -m)
43+
case "$ARCH" in
44+
arm64|aarch64)
45+
ARCH_SUFFIX="aarch64"
46+
;;
47+
x86_64|amd64|AMD64)
48+
ARCH_SUFFIX="x86_64"
49+
;;
50+
*)
51+
echo "Unsupported architecture: $ARCH" >&2
52+
exit 1
53+
;;
54+
esac
55+
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-windows-${ARCH_SUFFIX}.exe"
56+
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
57+
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
58+
echo "Will produce artifact: $ARTIFACT"
59+
shell: bash
60+
- name: Install Bazelisk (Bazel)
61+
shell: powershell
62+
run: |
63+
$arch = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
64+
switch ($arch) {
65+
'Arm64' { $suffix = 'arm64' }
66+
'X64' { $suffix = 'amd64' }
67+
default { Write-Error "Unsupported architecture: $arch"; exit 1 }
68+
}
69+
$url = "https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-windows-$suffix.exe"
70+
$destDir = "$env:RUNNER_TEMP"
71+
$dest = Join-Path $destDir 'bazelisk.exe'
72+
Write-Host "Downloading Bazelisk from $url to $dest"
73+
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $dest
74+
# Add to PATH for subsequent steps
75+
$destDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
76+
bazelisk version
77+
- name: Build protoc-gen-grpc-web with Bazel
78+
run: bazelisk --noworkspace_rc --bazelrc=.bazelrc.windows build //javascript/net/grpc/web/generator:protoc-gen-grpc-web
79+
shell: powershell
80+
- name: move
81+
run: |
82+
mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web.exe "./${ARTIFACT}"
83+
shell: bash
84+
- name: gen sha256
85+
run: |
86+
openssl dgst -sha256 -r -out "${ARTIFACT}.sha256" "${ARTIFACT}"
87+
shell: bash
88+
# TODO: Check sha256 (sha256sum not available for now.)
89+
#- name: verify sha256
90+
- name: Upload artifacts
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: ${{ steps.meta.outputs.artifact }}
94+
path: protoc-gen-grpc-web*

0 commit comments

Comments
 (0)