#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"

if [[ -f ".env" ]]; then
  set -a
  # shellcheck disable=SC1091
  source ".env"
  set +a
fi

: "${PYPI_API_TOKEN:?Set PYPI_API_TOKEN in .env or the environment.}"

uv tool run hatch build
uv tool run twine upload --non-interactive -u __token__ -p "$PYPI_API_TOKEN" dist/*
