Make macOS Plugin workflow (grpc/grpc-web)
The Make macOS Plugin workflow from grpc/grpc-web, explained and optimized by Latchkey.
C
CI health: C - fair
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Make macOS Plugin workflow from the grpc/grpc-web repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
workflow (.yml)
name: Make macOS Plugin
on:
push:
paths:
- .github/workflows/make-plugin-mac-os.yml
pull_request:
paths:
- .github/workflows/make-plugin-mac-os.yml
workflow_dispatch:
inputs:
version_number:
description: 'Version number'
required: true
default: '2.x.x'
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [macos-13, macos-14]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Compute VERSION_NUMBER
run: |
INPUT_VERSION="${{ github.event.inputs.version_number }}"
if [ -n "$INPUT_VERSION" ]; then
VERSION="$INPUT_VERSION"
else
VERSION="$GITHUB_REF_NAME"
fi
# Minimal sanitization: replace slashes with dashes to keep filenames valid
VERSION="${VERSION//\//-}"
echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV"
echo "Computed VERSION_NUMBER=$VERSION"
- name: Compute ARCH suffix and artifact name
id: meta
run: |
ARCH=$(uname -m)
case "$ARCH" in
arm64)
ARCH_SUFFIX="aarch64"
;;
x86_64)
ARCH_SUFFIX="x86_64"
;;
*)
echo "Unsupported architecture: $ARCH" >&2
exit 1
;;
esac
ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-darwin-${ARCH_SUFFIX}"
echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV"
echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT"
echo "Will produce artifact: $ARTIFACT"
- name: Install Bazelisk (Bazel)
run: |
brew update
brew install bazelisk
bazelisk version
- name: Build protoc-gen-grpc-web with Bazel
run: |
bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web
- name: Move artifact
run: |
mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web \
./${ARTIFACT}
- name: Generate sha256
run: |
openssl dgst -sha256 -r -out ${ARTIFACT}.sha256 \
${ARTIFACT}
- name: Verify sha256
run: shasum -a 256 -c ${ARTIFACT}.sha256
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ steps.meta.outputs.artifact }}
path: protoc-gen-grpc-web*
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Make macOS Plugin on: push: paths: - .github/workflows/make-plugin-mac-os.yml pull_request: paths: - .github/workflows/make-plugin-mac-os.yml workflow_dispatch: inputs: version_number: description: 'Version number' required: true default: '2.x.x' concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 strategy: fail-fast: false matrix: os: [macos-13, macos-14] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Compute VERSION_NUMBER run: | INPUT_VERSION="${{ github.event.inputs.version_number }}" if [ -n "$INPUT_VERSION" ]; then VERSION="$INPUT_VERSION" else VERSION="$GITHUB_REF_NAME" fi # Minimal sanitization: replace slashes with dashes to keep filenames valid VERSION="${VERSION//\//-}" echo "VERSION_NUMBER=$VERSION" >> "$GITHUB_ENV" echo "Computed VERSION_NUMBER=$VERSION" - name: Compute ARCH suffix and artifact name id: meta run: | ARCH=$(uname -m) case "$ARCH" in arm64) ARCH_SUFFIX="aarch64" ;; x86_64) ARCH_SUFFIX="x86_64" ;; *) echo "Unsupported architecture: $ARCH" >&2 exit 1 ;; esac ARTIFACT="protoc-gen-grpc-web-${VERSION_NUMBER}-darwin-${ARCH_SUFFIX}" echo "ARTIFACT=$ARTIFACT" >> "$GITHUB_ENV" echo "artifact=$ARTIFACT" >> "$GITHUB_OUTPUT" echo "Will produce artifact: $ARTIFACT" - name: Install Bazelisk (Bazel) run: | brew update brew install bazelisk bazelisk version - name: Build protoc-gen-grpc-web with Bazel run: | bazelisk build //javascript/net/grpc/web/generator:protoc-gen-grpc-web - name: Move artifact run: | mv bazel-bin/javascript/net/grpc/web/generator/protoc-gen-grpc-web \ ./${ARTIFACT} - name: Generate sha256 run: | openssl dgst -sha256 -r -out ${ARTIFACT}.sha256 \ ${ARTIFACT} - name: Verify sha256 run: shasum -a 256 -c ${ARTIFACT}.sha256 - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: ${{ steps.meta.outputs.artifact }} path: protoc-gen-grpc-web*
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job (2 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.