Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ inputs:
required: false
default: "true"
prebuilt:
description: Use prebuilt release binaries when the action is pinned to a release tag ("auto"), or always build from source ("never"). Downloads are checksum-verified against the release SHA256SUMS.
description: Use prebuilt release binaries when the action is pinned to a release tag or to a commit SHA that matches a release tag ("auto"), or always build from source ("never"). Downloads are checksum-verified against the release SHA256SUMS.
required: false
default: "auto"
binary:
Expand All @@ -89,10 +89,30 @@ runs:
shell: bash
env:
ACTION_REF: ${{ github.action_ref }}
GITHUB_API_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
echo "resolved=false" >> "$GITHUB_OUTPUT"
ref="${ACTION_REF:-}"
if [[ "$ref" =~ ^[0-9a-f]{40}$ ]] && command -v jq >/dev/null 2>&1; then
# Pinned by commit SHA (the recommended way to pin third-party
# actions). Resolve the commit to the release tag that points at it
# so SHA-pinned consumers still get prebuilt binaries instead of
# silently requiring libbpf build deps on the runner. Any API
# hiccup or no matching tag falls through to the source build.
tags_json="$(curl -fsSL --retry 2 \
-H "Authorization: Bearer ${GITHUB_API_TOKEN}" \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/Kernel-Guard/bpfcompat/tags?per_page=100" || true)"
resolved_tag="$(printf '%s' "$tags_json" \
| jq -r --arg sha "$ref" \
'[.[] | select(.commit.sha == $sha) | .name | select(test("^v[0-9]"))][0] // empty' \
2>/dev/null || true)"
if [[ -n "$resolved_tag" ]]; then
echo "Commit ${ref} is release ${resolved_tag}; using its prebuilt binaries."
ref="$resolved_tag"
fi
fi
if [[ ! "$ref" =~ ^v[0-9] ]]; then
echo "Action not pinned to a release tag (ref: ${ref:-none}); building from source."
exit 0
Expand Down
11 changes: 7 additions & 4 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest # exposes /dev/kvm for KVM acceleration
steps:
- uses: actions/checkout@v4
- uses: Kernel-Guard/bpfcompat@v0.2.0
- uses: Kernel-Guard/bpfcompat@v0.3.0
with:
artifact: build/program.bpf.o # your compiled object
matrix: matrices/mvp.yaml # the kernels you support
Expand All @@ -57,7 +57,7 @@ What you get:
Shipping a whole product? Use **suite mode** to gate a collection in one run:

```yaml
- uses: Kernel-Guard/bpfcompat@v0.2.0
- uses: Kernel-Guard/bpfcompat@v0.3.0
with:
suite: suites/project.yaml
suite-out: reports/suite.json
Expand All @@ -66,8 +66,11 @@ Shipping a whole product? Use **suite mode** to gate a collection in one run:

The Action is on the
[GitHub Marketplace](https://github.com/marketplace/actions/bpfcompat-ebpf-compatibility-gate).
Pinning to a release tag uses checksum-verified, attested prebuilt binaries
([verifying releases](verifying-releases.md)); otherwise it builds from source.
Pinning to a release tag — or to the commit SHA a release tag points at — uses
checksum-verified, attested prebuilt binaries
([verifying releases](verifying-releases.md)); otherwise it builds from source,
which needs `libbpf-dev`, `libelf-dev`, `zlib1g-dev`, and `pkg-config` on the
runner.

## 2. Run it locally (CLI)

Expand Down
Loading