.PHONY: sync test build upload upload-test clean docs-serve docs-build

sync:
	uv sync --all-extras

test:
	uv run pytest

docs-serve:
	uv run --extra docs mkdocs serve

docs-build:
	uv run --extra docs mkdocs build --strict

build: clean
	uv build

# uv publish doesn't read ~/.pypirc (that's a twine-only format) -- pull the
# token out of it and hand it over the way uv actually expects.
upload: build
	UV_PUBLISH_TOKEN=$$(python3 -c "import configparser,os;c=configparser.ConfigParser();c.read(os.path.expanduser('~/.pypirc'));print(c['pypi']['password'].strip())") uv publish

# Dry-run release against TestPyPI. Needs its own token: export
# UV_PUBLISH_TOKEN=<testpypi token> before running, or add a [testpypi]
# section to ~/.pypirc and extend the recipe above the same way.
upload-test: build
	uv publish --publish-url https://test.pypi.org/legacy/

clean:
	rm -rf dist build src/*.egg-info
