Files
asteria-qt/scripts/start-runner-macos.sh
T
Agel b05a2fecf8
Asteria Qt CI / rebuild-images (linux-x86_64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-arm64) (push) Skipped
Asteria Qt CI / rebuild-images (windows-x86_64) (push) Skipped
Asteria Qt CI / build-linux (push) Canceled after 0s
Asteria Qt CI / build-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / build-windows (push) Canceled after 0s
Asteria Qt CI / build-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / build-macos (push) Canceled after 0s
Asteria Qt CI / test-linux (push) Canceled after 0s
Asteria Qt CI / test-macos (push) Canceled after 0s
Asteria Qt CI / package-linux (push) Canceled after 0s
Asteria Qt CI / package-linux-arm64 (push) Canceled after 0s
Asteria Qt CI / rebuild-images (linux-arm64) (push) Skipped
Asteria Qt CI / package-windows (push) Canceled after 0s
Asteria Qt CI / package-windows-arm64 (push) Canceled after 0s
Asteria Qt CI / package-macos (push) Canceled after 0s
Asteria Qt CI / release (push) Canceled after 0s
swtich to gitea
2026-11-22 17:28:07 +01:00

100 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Start a local Gitea Actions Runner for macOS builds (host mode).
#
# First-time registration usage:
# RUNNER_TOKEN="..." ./scripts/start-runner-macos.sh
#
# Subsequent runs (once .runner exists):
# ./scripts/start-runner-macos.sh
set -euo pipefail
if [ "$(uname -s)" != "Darwin" ]; then
echo "ERROR: This script is intended for macOS only." >&2
exit 1
fi
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
RUNNER_BIN=""
if command -v gitea-runner >/dev/null 2>&1; then
RUNNER_BIN="gitea-runner"
elif command -v act_runner >/dev/null 2>&1; then
RUNNER_BIN="act_runner"
else
if ! command -v brew >/dev/null 2>&1; then
echo "ERROR: Homebrew is required to install gitea-runner. Please install Homebrew from https://brew.sh" >&2
exit 1
fi
echo "gitea-runner not found. Installing via Homebrew..."
brew install gitea-runner
if command -v gitea-runner >/dev/null 2>&1; then
RUNNER_BIN="gitea-runner"
else
RUNNER_BIN="act_runner"
fi
fi
RUNNER_CONFIG_DIR="${RUNNER_CONFIG_DIR:-$HOME/.gitea-runner}"
CONFIG_FILE="${RUNNER_CONFIG_DIR}/config.yaml"
RUNNER_FILE="${RUNNER_CONFIG_DIR}/.runner"
RUNNER_WORKDIR="${RUNNER_WORKDIR:-${RUNNER_CONFIG_DIR}/builds}"
GITEA_INSTANCE_URL="${GITEA_INSTANCE_URL:-${CI_SERVER_URL:-https://gitea.agel.dev}}"
RUNNER_NAME="${RUNNER_NAME:-asteria-qt-macos-runner}"
RUNNER_LABELS="${RUNNER_LABELS:-${RUNNER_TAGS:-macos-qt:host}}"
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
if command -v brew >/dev/null 2>&1; then
LIBARCHIVE_PREFIX="$(brew --prefix libarchive 2>/dev/null || true)"
if [ -n "${LIBARCHIVE_PREFIX}" ] && [ -d "${LIBARCHIVE_PREFIX}/lib/pkgconfig" ]; then
export PKG_CONFIG_PATH="${LIBARCHIVE_PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
fi
fi
mkdir -p "${RUNNER_CONFIG_DIR}" "${RUNNER_WORKDIR}"
cd "${RUNNER_CONFIG_DIR}"
cat > "${CONFIG_FILE}" <<EOF
log:
level: info
runner:
file: ${RUNNER_FILE}
capacity: 1
timeout: 3h
insecure: false
fetch_timeout: 5s
fetch_interval: 2s
labels:
- "${RUNNER_LABELS}"
cache:
enabled: true
dir: ${RUNNER_CONFIG_DIR}/cache
host:
workdir_parent: ${RUNNER_WORKDIR}
EOF
if [ ! -f "${RUNNER_FILE}" ]; then
TOKEN="${RUNNER_TOKEN:-${GITEA_RUNNER_REGISTRATION_TOKEN:-${REGISTRATION_TOKEN:-}}}"
if [ -n "${TOKEN}" ]; then
echo "Registering Gitea runner '${RUNNER_NAME}' at '${GITEA_INSTANCE_URL}' with labels '${RUNNER_LABELS}'..."
"${RUNNER_BIN}" register \
--no-interactive \
--config "${CONFIG_FILE}" \
--instance "${GITEA_INSTANCE_URL}" \
--token "${TOKEN}" \
--name "${RUNNER_NAME}" \
--labels "${RUNNER_LABELS}"
else
echo "ERROR: No runner registration found at ${RUNNER_FILE}." >&2
echo "Provide RUNNER_TOKEN from Gitea (Org/Repo Settings -> Actions -> Runners) to register first:" >&2
echo " RUNNER_TOKEN=<token> $0" >&2
exit 1
fi
fi
echo "Starting local macOS Gitea Runner (bin: ${RUNNER_BIN}, config: ${CONFIG_FILE}, workdir: ${RUNNER_WORKDIR})..."
exec "${RUNNER_BIN}" daemon --config "${CONFIG_FILE}"