Files
Skald-Circle/ci/verify-version.sh
dguiducci 8407a949fc
Nightly Build / build (push) Successful in 6m43s
ci, install: update workflows, packaging scripts, and installer suite
Nightly/release workflows: matrix tweaks, artifact path fixes.
Package-macos: streamline dmg build, codesigning improvements.
Install scripts: rewrite install.sh and install-nightly.sh with
robust error handling, add uninstall.sh, overhaul update.sh.
2026-07-22 15:11:17 +01:00

57 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env sh
# Verify that a Skald Circle release version has not been built yet.
#
# Intended as a required Gitea Actions status check on PRs to the `release`
# branch. Runs in the repo root after checkout.
#
# Usage:
# ./ci/verify-version.sh \
# --builds-dir /var/www/builds.skaldagent.net
#
# Exit codes:
# 0 → version is new (or builds-dir doesn't exist yet) → PR may proceed
# 1 → version already built → PR should fail
#
# Reads the version from Cargo.toml in the current directory.
set -eu
# ── Parse args ────────────────────────────────────────────────────────────────
BUILDS_DIR=""
while [ $# -gt 0 ]; do
case "$1" in
--builds-dir) BUILDS_DIR="$2"; shift 2 ;;
*) echo "[verify-version] Unknown option: $1" >&2; exit 1 ;;
esac
done
if [ -z "$BUILDS_DIR" ]; then
echo "[verify-version] Missing --builds-dir" >&2
exit 1
fi
# ── Read version from Cargo.toml ──────────────────────────────────────────────
# This is the workspace root's Cargo.toml.
VERSION="$(grep '^version ' Cargo.toml | head -1 | sed 's/version *= *"\(.*\)"/\1/')"
if [ -z "$VERSION" ]; then
echo "[verify-version] ERROR: Could not read version from Cargo.toml" >&2
exit 1
fi
echo "[verify-version] Version in Cargo.toml: v${VERSION}"
# ── Check if already built ────────────────────────────────────────────────────
RELEASE_DIR="${BUILDS_DIR}/releases/v${VERSION}"
if [ -d "$RELEASE_DIR" ]; then
echo "[verify-version] ❌ Release v${VERSION} already exists at:"
echo "[verify-version] ${RELEASE_DIR}"
echo "[verify-version] Bump the version in Cargo.toml before merging."
exit 1
fi
echo "[verify-version] ✅ Release v${VERSION} is new — no conflict."
exit 0