set shell := ["bash", "-eu", "-o", "pipefail", "-c"]

PYTHON := "python3.11"
PKG := "sg-core"
VERSION := "0.1.0"

help:
  @echo "Recipes:"
  @echo "  just venv         # create .venv with uv"
  @echo "  just tools        # install build + twine"
  @echo "  just clean        # remove dist/"
  @echo "  just build        # build sdist + wheel"
  @echo "  just test-upload  # upload to TestPyPI (prompts for token)"
  @echo "  just test-verify  # install from TestPyPI"
  @echo "  just prod-upload  # upload to PyPI (prompts for token)"

venv:
  uv venv --python {{PYTHON}}
  @echo "Run: source .venv/bin/activate"

tools:
  uv pip install -U build twine

clean:
  rm -rf dist

build: clean
  uv run python -m build
  @ls -lh dist

test-upload: build
  @echo "Uploading to TestPyPI..."
  export TWINE_USERNAME="__token__"
  read -s -p "TestPyPI token: " TWINE_PASSWORD; echo
  export TWINE_PASSWORD="$TWINE_PASSWORD"
  uv run python -m twine upload --repository testpypi dist/*

test-verify:
  @echo "Verifying install from TestPyPI..."
  uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple {{PKG}}=={{VERSION}} -v
  @echo "Installed {{PKG}}=={{VERSION}}"

prod-upload: build
  @echo "Uploading to PyPI..."
  export TWINE_USERNAME="__token__"
  read -s -p "PyPI token: " TWINE_PASSWORD; echo
  export TWINE_PASSWORD="$TWINE_PASSWORD"
  uv run python -m twine upload dist/*

