.PHONY: test lint typecheck check release-guard build smoke-build release verify-uvx

test:
	uv run pytest -q

lint:
	uv run --extra dev ruff check

typecheck:
	uv run --extra dev ty check

check: test lint typecheck

release-guard:
	uv run python scripts/check_release.py

build:
	uv build --clear

smoke-build: build
	uv run python scripts/smoke_built_wheel.py

release: release-guard check smoke-build
	@TOKEN=$$(python3 -c 'import configparser, pathlib; cfg = configparser.RawConfigParser(); cfg.read(pathlib.Path.home() / ".pypirc"); print(cfg.get("pypi", "password", fallback=""), end="")' 2>/dev/null); \
	test -n "$$TOKEN" || { echo "PyPI token not found in ~/.pypirc [pypi].password"; exit 1; }; \
	uv publish --token "$$TOKEN"

verify-uvx:
	@test -n "$$VERSION" || (echo "VERSION is required, e.g. make verify-uvx VERSION=0.2.10" && exit 1)
	uv run python scripts/smoke_built_wheel.py --package-spec skillchef==$$VERSION
