feat: bake product version from Spec and expose build in health.

Resolve MAJOR.MINOR via EventHubSpec/VERSION; CI run_number as EVENTHUB_BUILD; health returns version/build/git_sha/built_at.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-17 21:48:24 +03:00
parent 2b65a804d3
commit cd61aaff20
7 changed files with 72 additions and 4 deletions
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
# Product version (MAJOR.MINOR) из EventHubSpec/VERSION.
# Fallback: локальный VERSION (офлайн / без токена).
set -euo pipefail
BASE="${GITEA_BASE_URL:-https://git.sabilin.com}"
TOKEN="${GITEA_TOKEN:-${REGISTRY_PASSWORD:-}}"
REF="${PRODUCT_VERSION_REF:-master}"
FALLBACK_FILE="${PRODUCT_VERSION_FILE:-VERSION}"
fetch_spec() {
local url="${BASE}/api/v1/repos/EventHub/EventHubSpec/raw/VERSION?ref=${REF}"
if [[ -n "${TOKEN}" ]]; then
curl -fsSL -H "Authorization: token ${TOKEN}" "${url}"
else
curl -fsSL "${url}"
fi
}
ver=""
if raw="$(fetch_spec 2>/dev/null)"; then
ver="$(printf '%s' "${raw}" | grep -Eo '[0-9]+\.[0-9]+' | head -1 || true)"
fi
if [[ -z "${ver}" && -f "${FALLBACK_FILE}" ]]; then
echo "WARN: EventHubSpec/VERSION недоступен — fallback ${FALLBACK_FILE}" >&2
ver="$(grep -Eo '[0-9]+\.[0-9]+' "${FALLBACK_FILE}" | head -1 || true)"
fi
if [[ -z "${ver}" ]]; then
echo "ERROR: не удалось получить product version (Spec + local VERSION)" >&2
exit 1
fi
if ! [[ "${ver}" =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: некорректный VERSION '${ver}' (ожидается MAJOR.MINOR)" >&2
exit 1
fi
printf '%s\n' "${ver}"