#!/usr/bin/env bash # Shared helpers for scripts/ci/*.sh. Everything here is plain bash so the same script # runs identically on a developer's machine and on a bare CI runner. set -euo pipefail log() { echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] $*" } fail() { echo "[$(date -u +'%Y-%m-%dT%H:%M:%SZ')] ERROR: $*" >&2 exit 1 } # Repo root, regardless of the caller's cwd. CI_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" # Prepends a locally installed .NET SDK to PATH when `dotnet` is missing, so a runner # with no SDK preinstalled behaves the same as a dev machine. ensure_dotnet() { if command -v dotnet > /dev/null 2>&1; then return 0 fi local install_dir="$CI_ROOT/.dotnet" if [[ ! -x "$install_dir/dotnet" ]]; then log "dotnet not found on PATH; installing the .NET SDK" curl -fsSL https://dot.net/v1/dotnet-install.sh -o "/tmp/dotnet-install.sh" bash "/tmp/dotnet-install.sh" --channel STS --install-dir "$install_dir" rm -f "/tmp/dotnet-install.sh" fi export PATH="$install_dir:$PATH" export DOTNET_ROOT="$install_dir" } ensure_node() { command -v npm > /dev/null 2>&1 || fail "npm not found on PATH; install Node.js to build the web client" }