#!/usr/bin/env bash # The scripts suite executes the Fastfile's signing-lock logic with Ruby's # standard library. CI's non-login PATH omits rbenv even when Ruby is installed. # Activate that interpreter for the job; never silently skip the guard. set -euo pipefail ruby="" if [ "$#" -gt 0 ]; then [ "$#" -eq 2 ] && [ "$1" = --rbenv ] || { echo "usage: $0 [--rbenv ]" >&2; exit 2; } roots=("$2") else ruby="$(command -v ruby || true)" roots=("${RBENV_ROOT:-$HOME/.rbenv}" /opt/rbenv /opt/homebrew/opt/rbenv) fi if [ -z "$ruby" ]; then for root in "${roots[@]}"; do [ -x "$root/bin/rbenv" ] || continue candidate="$(RBENV_ROOT="$root" "$root/bin/rbenv" which ruby 2>/dev/null || true)" if [ -n "$candidate" ] && [ -x "$candidate" ]; then ruby="$candidate"; break; fi done fi if [ -z "$ruby" ]; then echo "::error::Ruby is required for the script signing-lock guard; install Ruby on this runner or name its rbenv root." >&2 exit 1 fi "$ruby" --version printf '%s\n' "$(dirname "$ruby")" >> "${GITHUB_PATH:-/dev/null}" echo "test-ruby: $ruby"