-
Notifications
You must be signed in to change notification settings - Fork 12
Fully support sha pinning + remove docker from runtime. #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
BakerNet
merged 8 commits into
multimediallc:main
from
Icantjuddle:remove_docker_runtime
Jun 17, 2026
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
448bec3
Get rid of docker
Icantjuddle ba82e53
full reproducible
Icantjuddle 7c781b8
Simplify scripts
BakerNet 4e17f45
Add back in caching and tar
BakerNet b30e0ca
Restore build binary caching
BakerNet bd23060
Consistent cache key naming nit
BakerNet e9d1bd3
Minor fixes
BakerNet 2cc6c15
Only run goreleaser-action on draft to be compatible with immutable r…
BakerNet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #! /usr/bin/env bash | ||
| # Installs the release binary at BIN, verified against EXPECTED_SHA256 (the | ||
| # checksum from the pinned commit): downloads on a cache miss, re-verifies | ||
| # the (untrusted, repo-scoped) cached copy on a cache hit. | ||
|
|
||
| set -eu | ||
|
|
||
| : "${RELEASE_VERSION:?RELEASE_VERSION must be set}" "${ACTION_REPO:?ACTION_REPO must be set}" \ | ||
| "${ASSET:?ASSET must be set}" "${BIN:?BIN must be set}" "${EXPECTED_SHA256:?EXPECTED_SHA256 must be set}" | ||
|
|
||
| # Downloads the release binary and installs it to BIN if it matches | ||
| # EXPECTED_SHA256. | ||
| fetch() { | ||
| local dest | ||
| dest="$(mktemp)" | ||
|
BakerNet marked this conversation as resolved.
Outdated
|
||
| echo "Downloading ${ASSET} from release ${RELEASE_VERSION}" >&2 | ||
| curl -fsSL --retry 3 -o "${dest}" \ | ||
| "https://github.com/${ACTION_REPO}/releases/download/${RELEASE_VERSION}/${ASSET}" | ||
| if ! echo "${EXPECTED_SHA256} ${dest}" | sha256sum -c --quiet -; then | ||
|
BakerNet marked this conversation as resolved.
Outdated
|
||
| echo "Error: downloaded ${ASSET} does not match the checksum in the pinned commit" >&2 | ||
| exit 1 | ||
| fi | ||
| mkdir -p "$(dirname "${BIN}")" | ||
| mv "${dest}" "${BIN}" | ||
| chmod +x "${BIN}" | ||
| } | ||
|
|
||
| if [ -x "${BIN}" ]; then | ||
| if echo "${EXPECTED_SHA256} ${BIN}" | sha256sum -c --quiet - >/dev/null 2>&1; then | ||
|
BakerNet marked this conversation as resolved.
Outdated
|
||
| echo "Cached binary checksum matched (${EXPECTED_SHA256})" >&2 | ||
| exit 0 | ||
| fi | ||
| echo "Warning: cached binary checksum mismatch; discarding cache and re-fetching." >&2 | ||
| rm -f "${BIN}" | ||
| fi | ||
| fetch | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #! /usr/bin/env bash | ||
| # Decides how the action binary is obtained, emitting mode=download|build | ||
| # (plus bin/version/sha256/asset/cache-key) to $GITHUB_OUTPUT. Pins to the | ||
| # release tag or a release commit's SHA download the prebuilt binary, | ||
| # verified against the checksums baked into the pinned commit (set in | ||
| # action.yml only in release commits); all other refs build from the | ||
| # checked-out source. A pin never resolves to anything newer than itself. | ||
|
|
||
| set -eu | ||
|
|
||
| RELEASE_VERSION="${RELEASE_VERSION:-}" | ||
|
|
||
| if [ "${RUNNER_OS:-Linux}" != "Linux" ]; then | ||
| echo "Error: codeowners-plus only supports Linux runners (got '${RUNNER_OS}')." >&2 | ||
| exit 1 | ||
| fi | ||
| arch="" | ||
| expected="" | ||
| case "${RUNNER_ARCH:-X64}" in | ||
| X64) | ||
| arch="amd64" | ||
| expected="${SHA256_LINUX_AMD64:-}" | ||
| ;; | ||
| ARM64) | ||
| arch="arm64" | ||
| expected="${SHA256_LINUX_ARM64:-}" | ||
| ;; | ||
| esac | ||
|
|
||
| { | ||
| echo "bin=${RUNNER_TEMP:-/tmp}/codeowners-plus-action/codeowners-plus" | ||
| echo "version=${RELEASE_VERSION}" | ||
| echo "sha256=${expected}" | ||
| } >>"$GITHUB_OUTPUT" | ||
|
|
||
| # A release-tag pin or a SHA pin of a release commit downloads the prebuilt | ||
| # binary; the embedded checksum makes the result immutable either way. | ||
| # Mutable refs (branches) always build from the checked-out source. | ||
| pinned_to_release=false | ||
| if [ -n "${RELEASE_VERSION}" ] && [ -n "${expected}" ]; then | ||
| if [ "${ACTION_REF:-}" = "${RELEASE_VERSION}" ] || [[ "${ACTION_REF:-}" =~ ^[0-9a-f]{40}$ ]]; then | ||
| pinned_to_release=true | ||
| fi | ||
| fi | ||
|
|
||
| if [ -n "${ACTION_REPO:-}" ] && [ "${pinned_to_release}" = "true" ] && [ -n "${arch}" ]; then | ||
| echo "Action pinned to release '${RELEASE_VERSION}' (ref '${ACTION_REF}'); using prebuilt binary." >&2 | ||
| { | ||
| echo "mode=download" | ||
| echo "asset=codeowners-plus-action_linux_${arch}" | ||
| # Content-addressed: the key names exactly the verified binary bytes. | ||
| echo "cache-key=codeowners-plus-action-bin-${expected}" | ||
| } >>"$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Action ref '${ACTION_REF:-<unknown>}' is not a release; building from source." >&2 | ||
| echo "mode=build" >>"$GITHUB_OUTPUT" | ||
| if [[ "${ACTION_REF:-}" =~ ^[0-9a-f]{40}$ ]]; then | ||
| # Immutable commit pin: safe to cache the built binary. | ||
| echo "cache-key=codeowners-plus-action-src-${ACTION_REF}-linux-${arch:-${RUNNER_ARCH:-unknown}}" >>"$GITHUB_OUTPUT" | ||
| else | ||
| # Branch or other mutable ref: never cache, always build fresh. | ||
| echo "cache-key=" >>"$GITHUB_OUTPUT" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #! /usr/bin/env bash | ||
|
|
||
| # Build script for the github action binary. | ||
| # Single source of truth for build settings since we build in both | ||
| # prepare-release (to get the binary shasum) and | ||
| # in the actual release step (to get the artifact). | ||
|
|
||
| set -eu | ||
|
|
||
| out="$1" | ||
| arch="${2:-$(go env GOARCH)}" | ||
|
|
||
| cd "$(dirname "${BASH_SOURCE[0]}")/.." | ||
|
BakerNet marked this conversation as resolved.
Outdated
|
||
| GOOS=linux GOARCH="${arch}" CGO_ENABLED=0 \ | ||
| go build -trimpath -buildvcs=false -ldflags="-s -w" -o "${out}" . | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a separate cache action for build vs download, the cached path is the same.