Files
hyperstitionstudio-core/deploy/push-all-to-git-libre-audio.sh
T

247 lines
11 KiB
Bash
Executable File

#!/usr/bin/env bash
# /workspace/push-all-to-git-libre-audio.sh
# Release v2.17.1: Pre-push verification & topological push of all 6 repositories to git.libre.audio.
set -euo pipefail
on_error() {
local exit_code=$?
local line_no="${1:-unknown}"
echo "[ERROR] push-all-to-git-libre-audio.sh failed at line ${line_no} with exit code ${exit_code} while running: ${BASH_COMMAND}" >&2
exit "${exit_code}"
}
trap 'on_error ${LINENO}' ERR
run_checked() {
local label="$1"
shift
local out=""
local rc=0
out="$("$@" 2>&1)" || rc=$?
if [[ "${rc}" -ne 0 ]]; then
echo "[ERROR] ${label} failed (exit code ${rc}): $*" >&2
if [[ -n "${out}" ]]; then
echo "${out}" >&2
fi
return "${rc}"
fi
}
ensure_remote_url() {
local repo_dir="$1"
local remote_name="$2"
local target_url="$3"
if git -C "${repo_dir}" remote | grep -qx "${remote_name}"; then
run_checked "git remote set-url ${remote_name} (${repo_dir})" git -C "${repo_dir}" remote set-url "${remote_name}" "${target_url}"
else
run_checked "git remote add ${remote_name} (${repo_dir})" git -C "${repo_dir}" remote add "${remote_name}" "${target_url}"
fi
}
SCRIPT_PATH="${BASH_SOURCE[0]:-$0}"
DEFAULT_WS_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)"
if [[ ! -d "${DEFAULT_WS_DIR}/hyperstitionstudio-core/src" ]] && [[ -d "/workspace/hyperstitionstudio-core/src" ]]; then
DEFAULT_WS_DIR="/workspace"
fi
export WORKSPACE_DIR="${WORKSPACE_DIR:-${DEFAULT_WS_DIR}}"
export PYTHONPATH="${WORKSPACE_DIR}/hyperstitionstudio-core/src${PYTHONPATH:+:${PYTHONPATH}}"
export HYPERSTITIONSTUDIO_CONFIG="${HYPERSTITIONSTUDIO_CONFIG:-${WORKSPACE_DIR}/workspace.toml}"
FORGE_SSH="${FORGE_SSH:-ssh://git@git.libre.audio:2222/seasharp}"
EXEGESIS_HOST="${EXEGESIS_HOST:-}"
EXEGESIS_UNINSTALL=0
SKIP_EXEGESIS_DEPLOY=0
while [[ $# -gt 0 ]]; do
case "$1" in
--exegesis-host=*)
EXEGESIS_HOST="${1#*=}"
shift
;;
--exegesis-host)
if [[ $# -lt 2 ]] || [[ -z "${2:-}" ]]; then
echo "[ERROR] --exegesis-host requires a <user@host> argument." >&2
exit 2
fi
EXEGESIS_HOST="$2"
shift 2
;;
--exegesis-uninstall)
EXEGESIS_UNINSTALL=1
shift
;;
--skip-exegesis-deploy)
SKIP_EXEGESIS_DEPLOY=1
shift
;;
-h|--help)
echo "Usage: $0 [--exegesis-host=<user@host>] [--exegesis-uninstall] [--skip-exegesis-deploy]"
exit 0
;;
*)
echo "[ERROR] Unknown option: $1" >&2
echo "Usage: $0 [--exegesis-host=<user@host>] [--exegesis-uninstall] [--skip-exegesis-deploy]" >&2
exit 2
;;
esac
done
if [[ "${EXEGESIS_UNINSTALL}" -eq 1 ]]; then
if [[ -z "${EXEGESIS_HOST}" ]] && [[ -t 0 ]]; then
read -r -p "Enter target Fedora 41 host (user@host) to uninstall ingglish-isopsephic-exegesis: " EXEGESIS_HOST || EXEGESIS_HOST=""
fi
if [[ -z "${EXEGESIS_HOST}" ]]; then
echo "[ERROR] --exegesis-uninstall requires --exegesis-host=<user@host>." >&2
exit 2
fi
echo "[uninstall] Verifying SSH connectivity to ${EXEGESIS_HOST}..."
ssh -o BatchMode=yes -o ConnectTimeout=5 "${EXEGESIS_HOST}" true
echo "[uninstall] Uninstalling ingglish-isopsephic-exegesis on ${EXEGESIS_HOST}..."
if [[ -t 0 ]]; then
ssh -t "${EXEGESIS_HOST}" sudo rpm -e ingglish-isopsephic-exegesis
else
ssh "${EXEGESIS_HOST}" sudo rpm -e ingglish-isopsephic-exegesis
fi
echo "[OK] Cleanly uninstalled ingglish-isopsephic-exegesis from ${EXEGESIS_HOST}."
exit 0
fi
echo "[info] WORKSPACE_DIR=${WORKSPACE_DIR}"
echo "[info] PYTHONPATH=${PYTHONPATH}"
echo "[1/3] Running pre-push verification gates (hs-archive-rotate, hs-readme-sync, version_sync --corpus-delta, periodic harvest CI/CD flow diagram PNG, Fedora 41 RPM & dry-run, test_core_suite, 6-gate graph verifier)..."
run_checked "hs-archive-rotate --enforce-single-compression" python3 -m hyperstitionstud_io.publishing.archive_rotator --workspace-root "${WORKSPACE_DIR}" --enforce-single-compression
run_checked "hs-readme-sync --install-hooks" python3 -m hyperstitionstud_io.publishing.readme_sync --install-hooks
run_checked "version_sync --corpus-delta" python3 -m hyperstitionstud_io.version_sync --corpus-delta
run_checked "generate & verify periodic-harvest-cicd-to-vps-flow-diagram.png" python3 -m hyperstitionstud_io.publishing.flow_diagram
run_checked "verify periodic-harvest-cicd-to-vps-flow-diagram.png exists" test -s "${WORKSPACE_DIR}/encyclopedia-knowledge-graph/docs/periodic-harvest-cicd-to-vps-flow-diagram.png"
run_checked "verify Fedora 41 packaging scripts & spec" "${WORKSPACE_DIR}/ingglish-hyperdope-gematria/packaging/build-fedora41-rpm.sh"
run_checked "verify Fedora 41 exegesis push worker dry-run" "${WORKSPACE_DIR}/ingglish-hyperdope-gematria/packaging/bundle/scripts/run_exegesis_and_push_fedora41.sh" --dry-run
python3 "${WORKSPACE_DIR}/hyperstitionstudio-core/tests/test_core_suite.py"
run_checked "build_encyclopedia_knowledge_graph.py --verify-only" python3 "${WORKSPACE_DIR}/encyclopedia-knowledge-graph/scripts/build_encyclopedia_knowledge_graph.py" --verify-only
echo "[2/3] Verifying git.libre.audio remote URLs across all repositories..."
CI_REPO_DIR="hyperdope-ci-build"
if [[ ! -d "${WORKSPACE_DIR}/${CI_REPO_DIR}" ]] && [[ -d "${WORKSPACE_DIR}/ingglish-hyperdope-ci" ]]; then
CI_REPO_DIR="ingglish-hyperdope-ci"
fi
for pair in \
"hyperstitionstudio-core:hyperstitionstudio-core.git" \
"ingglish-hyperdope-gematria:ingglish-hyperdope-gematria.git" \
"technocapital-singularity-zoology:technocapital-singularity-zoology.git" \
"encyclopedia-knowledge-graph:encyclopedia-knowledge-graph.git" \
"${CI_REPO_DIR}:ingglish-hyperdope-ci.git"; do
rdir="${WORKSPACE_DIR}/${pair%%:*}"
rslug="${pair##*:}"
ensure_remote_url "${rdir}" origin "${FORGE_SSH}/${rslug}"
done
push_head_tag() {
local repo_dir="$1"
local remote_name="$2"
local head_tag=""
head_tag="$(git -C "${repo_dir}" tag --points-at HEAD | sort -V | tail -n 1)"
if [[ -n "${head_tag}" ]]; then
run_checked "git push tag ${head_tag} (${repo_dir})" git -C "${repo_dir}" push --force "${remote_name}" "refs/tags/${head_tag}"
fi
}
echo "[3/3] Rebasing any automated VPS telemetry commits & pushing all 6 repositories and HEAD release tags in topological dependency order to ${FORGE_SSH}..."
echo " -> (1/6) hyperstitionstudio-core (main + HEAD tag)"
git -C "${WORKSPACE_DIR}/hyperstitionstudio-core" pull --rebase --autostash origin main || true
git -C "${WORKSPACE_DIR}/hyperstitionstudio-core" push -u origin main
push_head_tag "${WORKSPACE_DIR}/hyperstitionstudio-core" origin
echo " -> (2/6) ingglish-hyperdope-gematria (main + HEAD tag)"
git -C "${WORKSPACE_DIR}/ingglish-hyperdope-gematria" pull --rebase --autostash origin main || true
git -C "${WORKSPACE_DIR}/ingglish-hyperdope-gematria" push -u origin main
push_head_tag "${WORKSPACE_DIR}/ingglish-hyperdope-gematria" origin
echo " -> (3/6) technocapital-singularity-zoology (main + HEAD tag)"
git -C "${WORKSPACE_DIR}/technocapital-singularity-zoology" pull --rebase --autostash origin main || true
git -C "${WORKSPACE_DIR}/technocapital-singularity-zoology" push -u origin main
push_head_tag "${WORKSPACE_DIR}/technocapital-singularity-zoology" origin
echo " -> (4/6) encyclopedia-knowledge-graph (main + HEAD tag)"
git -C "${WORKSPACE_DIR}/encyclopedia-knowledge-graph" pull --rebase --autostash origin main || true
git -C "${WORKSPACE_DIR}/encyclopedia-knowledge-graph" push -u origin main
push_head_tag "${WORKSPACE_DIR}/encyclopedia-knowledge-graph" origin
echo " -> (5/6) hyperdope-ci-build (${CI_REPO_DIR}, feat/ingglish-aq-corpus + HEAD tag)"
git -C "${WORKSPACE_DIR}/${CI_REPO_DIR}" pull --rebase --autostash origin feat/ingglish-aq-corpus || true
git -C "${WORKSPACE_DIR}/${CI_REPO_DIR}" push -u origin feat/ingglish-aq-corpus
push_head_tag "${WORKSPACE_DIR}/${CI_REPO_DIR}" origin
if [[ -d "${WORKSPACE_DIR}/haiperdohp-jemaytreeah/.git" ]]; then
echo " -> (6/6) haiperdohp-jemaytreeah (downstream main, feat/ingglish-aq-corpus, feat/ingglish-priority-toggle + HEAD tag)"
ensure_remote_url "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" downstream "${FORGE_SSH}/haiperdohp-jemaytreeah.git"
git -C "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" fetch downstream || true
git -C "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" pull --rebase --autostash downstream main || true
git -C "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" pull --rebase --autostash downstream feat/ingglish-aq-corpus || true
git -C "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" pull --rebase --autostash downstream feat/ingglish-priority-toggle || true
git -C "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" push downstream main feat/ingglish-aq-corpus feat/ingglish-priority-toggle
push_head_tag "${WORKSPACE_DIR}/haiperdohp-jemaytreeah" downstream
fi
echo "[OK] All 6 repositories and release tags pushed to ${FORGE_SSH}."
if [[ "${SKIP_EXEGESIS_DEPLOY}" -eq 1 ]]; then
echo "[info] Skipping Fedora 41 exegesis RPM over-the-wire deployment (--skip-exegesis-deploy)."
elif [[ -z "${EXEGESIS_HOST}" ]] && [[ -t 0 ]]; then
read -r -p "Deploy built Fedora 41 exegesis RPM over the wire via SSH? [y/N / enter user@host]: " EXEGESIS_INPUT || EXEGESIS_INPUT=""
EXEGESIS_INPUT="${EXEGESIS_INPUT#"${EXEGESIS_INPUT%%[![:space:]]*}"}"
EXEGESIS_INPUT="${EXEGESIS_INPUT%"${EXEGESIS_INPUT##*[![:space:]]}"}"
case "${EXEGESIS_INPUT}" in
""|n|N|no|NO)
echo "[info] Skipping Fedora 41 exegesis RPM over-the-wire deployment."
;;
y|Y|yes|YES)
read -r -p "Enter target Fedora 41 host (user@host or IP): " EXEGESIS_HOST || EXEGESIS_HOST=""
EXEGESIS_HOST="${EXEGESIS_HOST#"${EXEGESIS_HOST%%[![:space:]]*}"}"
EXEGESIS_HOST="${EXEGESIS_HOST%"${EXEGESIS_HOST##*[![:space:]]}"}"
;;
*)
EXEGESIS_HOST="${EXEGESIS_INPUT}"
;;
esac
elif [[ -z "${EXEGESIS_HOST}" ]]; then
echo "[info] Non-interactive session and --exegesis-host not set; skipping Fedora 41 exegesis RPM deployment."
fi
if [[ "${SKIP_EXEGESIS_DEPLOY}" -eq 0 ]] && [[ -n "${EXEGESIS_HOST}" ]]; then
echo "[deploy] Verifying SSH connectivity to ${EXEGESIS_HOST}..."
ssh -o BatchMode=yes -o ConnectTimeout=5 "${EXEGESIS_HOST}" true
RPM_FILE=""
shopt -s nullglob
RPM_CANDIDATES=(
"${WORKSPACE_DIR}/ingglish-hyperdope-gematria/packaging"/ingglish-isopsephic-exegesis-*.fc41.noarch.rpm
"${WORKSPACE_DIR}/untracked/rpm-builds"/ingglish-isopsephic-exegesis-*.fc41.noarch.rpm
)
shopt -u nullglob
if [[ ${#RPM_CANDIDATES[@]} -gt 0 ]]; then
RPM_FILE="$(printf '%s\n' "${RPM_CANDIDATES[@]}" | sort -V | tail -n 1)"
fi
if [[ -z "${RPM_FILE}" ]] || [[ ! -f "${RPM_FILE}" ]]; then
echo "[ERROR] No built Fedora 41 RPM found in ${WORKSPACE_DIR}/ingglish-hyperdope-gematria/packaging/ or ${WORKSPACE_DIR}/untracked/rpm-builds/." >&2
exit 1
fi
RPM_NAME="$(basename "${RPM_FILE}")"
echo "[deploy] Found built RPM: ${RPM_FILE}"
echo "[deploy] Transferring ${RPM_NAME} to ${EXEGESIS_HOST}:/tmp/${RPM_NAME}..."
scp "${RPM_FILE}" "${EXEGESIS_HOST}:/tmp/${RPM_NAME}"
echo "[deploy] Installing/upgrading ${RPM_NAME} on ${EXEGESIS_HOST}..."
if [[ -t 0 ]]; then
ssh -t "${EXEGESIS_HOST}" "sudo rpm -Uvh --replacepkgs /tmp/${RPM_NAME} && rm -f /tmp/${RPM_NAME}"
else
ssh "${EXEGESIS_HOST}" "sudo rpm -Uvh --replacepkgs /tmp/${RPM_NAME} && rm -f /tmp/${RPM_NAME}"
fi
echo "[deploy] Running in-situ dry-run verification on ${EXEGESIS_HOST}..."
ssh "${EXEGESIS_HOST}" "/usr/bin/ingglish-exegesis-push --dry-run"
echo "[OK] Verified in-situ execution of /usr/bin/ingglish-exegesis-push --dry-run on ${EXEGESIS_HOST}."
echo "[rollback] To reverse this installation on ${EXEGESIS_HOST}, run: ssh ${EXEGESIS_HOST} sudo rpm -e ingglish-isopsephic-exegesis"
fi