#!/usr/bin/env bash
# Version for experimental/tspl2 builds: <Cargo.toml version>-tspl2.<pipeline id>.
# Never a bare X.Y.Z, so it can never collide with a stable release or AUR.
set -euo pipefail
cd "$(dirname "$0")/../.."
base="$(grep -m1 '^version = ' Cargo.toml | sed -E 's/.*"([^"]+)"/\1/')"
base="${base%%-*}"
mkdir -p artifacts
v="${base}-tspl2.${CI_PIPELINE_ID:-0}"
[[ "$v" =~ ^[0-9]+\.[0-9]+\.[0-9]+-tspl2\.[0-9]+$ ]] || { echo "Invalid experimental version: $v" >&2; exit 1; }
echo "$v" | tee artifacts/version.txt
