# Cardog Python SDK — the v2 surface is GENERATED from the contracts artifact.
#
#   make generate       emit openapi.v2.json from @cardog/contracts, then regenerate
#                       src/cardog/v2/ (types + group resources) and the vendored spec
#   make test           unit tests (mocked transport; live smoke skips without env)
#   make check          generate twice + assert zero diff (idempotency gate) + tests
#   make publish-check  clean build (sdist + wheel via uv) + twine-validate, no upload
#   make publish        RETIRED — nothing publishes from a laptop. Merging a
#                       version bump to master runs .github/workflows/release-pypi.yml,
#                       which publishes by PyPI trusted publishing (no token).

.PHONY: generate spec codegen test check publish publish-check build-dist

spec:
	cd ../.. && pnpm --filter @cardog/contracts spec

codegen:
	python3 scripts/generate.py

generate: spec codegen

test:
	.venv/bin/python -m pytest -q

check: generate
	python3 scripts/generate.py
	git diff --exit-code -- src/cardog/v2 openapi
	$(MAKE) test

# Clean build: wipes dist/ (including any stale 0.x artifacts) before building.
build-dist:
	rm -rf dist
	uv build

publish-check: build-dist
	twine check dist/*

# Retired 2026-09-30. Releases go out from .github/workflows/release-pypi.yml
# on merge to master (PyPI trusted publishing, no token on any laptop). To
# ship: bump `version` in pyproject.toml, SDK_VERSION in src/cardog/_constants.py
# and the CHANGELOG heading together, then merge.
publish:
	@echo "make publish is retired: nothing publishes from a laptop."
	@echo "Bump pyproject.toml [project] version, src/cardog/_constants.py SDK_VERSION and the CHANGELOG.md heading, merge to master, and .github/workflows/release-pypi.yml publishes it (PyPI trusted publishing)."
	@exit 1
