Files
Andrey Vasnetsov 070ca541fd ci: centralize protoc setup in a composite action (#8805)
* ci: centralize protoc setup in a composite action

Add .github/actions/setup-protoc that pins both the arduino/setup-protoc
SHA and the protoc version (34.1) in one place, so future bumps no longer
require touching every workflow.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* ci: replace arduino/setup-protoc with direct release-zip download

The arduino action queries the GitHub API on every invocation even when
the version is fully pinned, which is unnecessary work. Inline a small
shell step that downloads the protoc release zip directly using
RUNNER_OS/RUNNER_ARCH for asset selection. Supports Linux, macOS, and
Windows (x64 + arm64 where protobuf publishes assets).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 23:11:40 +02:00

48 lines
1.5 KiB
YAML

name: Install Protoc
description: "Install a pinned protoc by downloading the release zip directly (no GitHub API calls)"
inputs:
version:
description: "Protoc version, without the leading 'v'"
required: false
default: "34.1"
runs:
using: "composite"
steps:
- name: Download and install protoc ${{ inputs.version }}
shell: bash
env:
PROTOC_VERSION: ${{ inputs.version }}
run: |
set -euo pipefail
case "$RUNNER_OS-$RUNNER_ARCH" in
Linux-X64) suffix="linux-x86_64" ;;
Linux-ARM64) suffix="linux-aarch_64" ;;
macOS-X64) suffix="osx-x86_64" ;;
macOS-ARM64) suffix="osx-aarch_64" ;;
Windows-X64) suffix="win64" ;;
Windows-X86) suffix="win32" ;;
*)
echo "::error::Unsupported runner: $RUNNER_OS-$RUNNER_ARCH"
exit 1
;;
esac
install_dir="$RUNNER_TEMP/protoc-$PROTOC_VERSION"
zip="$RUNNER_TEMP/protoc.zip"
url="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${suffix}.zip"
echo "Downloading $url"
curl -fsSL --retry 3 --retry-delay 2 -o "$zip" "$url"
mkdir -p "$install_dir"
unzip -q -o "$zip" -d "$install_dir"
rm -f "$zip"
chmod +x "$install_dir/bin/"* 2>/dev/null || true
echo "$install_dir/bin" >> "$GITHUB_PATH"
"$install_dir/bin/protoc" --version