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

# Publish parallel-stats to PyPI.
# Prerequisites:
#   - A PyPI API token (set PYPI_TOKEN env var, or you'll be prompted)
#   - uv installed

echo "Building..."
uv build

echo ""
echo "Built artifacts:"
ls -lh dist/

echo ""
read -p "Upload to PyPI? [y/N] " confirm
if [[ "$confirm" != [yY] ]]; then
    echo "Aborted."
    exit 0
fi

if [[ -n "${PYPI_TOKEN:-}" ]]; then
    uv publish --token "$PYPI_TOKEN"
else
    uv publish
fi

echo ""
echo "Done. https://pypi.org/project/one-pass-stats/"
