.ONESHELL:
SHELL := /bin/zsh

version = 0.5.0

test:
	@if [[ -z "$(example)" ]]; then \
		echo "usage: make test example=01"; \
		exit 1; \
	fi; \
	setopt localoptions null_glob; \
	matches=(examples/$(example)-*.py); \
	if (( $${#matches} == 0 )); then \
		echo "no example found for prefix: $(example)"; \
		exit 1; \
	fi; \
	if (( $${#matches} > 1 )); then \
		echo "multiple examples match prefix $(example):"; \
		printf '  %s\n' "$${matches[@]}"; \
		echo "use a more specific prefix, e.g. example=19"; \
		exit 1; \
	fi; \
	script="$${matches[1]##examples/}"; \
	cd examples; \
	PYTHONPATH=.. ../.venv-macos/bin/python "$$script"

upload:
	python -m build
	python -m twine upload dist/*
	git tag -a v$(version) -m "v$(version)"
	git push origin v$(version)
	gh release create v$(version) dist/*


.PHONY: test
