coren 0.1.1

Machine capability detection and compute normalization
Documentation
.PHONY: build test dev wheel clean release first-release

build:
	cargo build --release

test:
	cargo test

dev:
	uv run maturin develop --features python

wheel:
	uv run maturin build --release --strip

clean:
	cargo clean
	rm -rf target/wheels __pycache__

# --- Releasing ---
#
# Credentials are read from local dotfiles (gitignored):
#   .pypirc             - PyPI API token
#   .cargo-credentials  - crates.io API token
#   .release-token      - Codeberg personal access token
#
# Copy the .example files and fill in your tokens:
#   cp .pypirc.example .pypirc
#   cp .cargo-credentials.example .cargo-credentials
#   cp .release-token.example .release-token

# First-ever release. Publishes to PyPI + crates.io from local files.
# Run once, then use 'make release V=x.y.z' for all future releases.
first-release: wheel
	uv run maturin sdist -o target/wheels/
	@test -f .pypirc || (echo "Missing .pypirc -- cp .pypirc.example .pypirc" && exit 1)
	@test -f .cargo-credentials || (echo "Missing .cargo-credentials -- cp .cargo-credentials.example .cargo-credentials" && exit 1)
	@echo "--- Uploading to PyPI ---"
	uv tool install twine
	uv run twine upload --config-file .pypirc target/wheels/*.whl target/wheels/*.tar.gz
	@echo "--- Publishing to crates.io ---"
	cargo publish --token "$$(grep '^token' .cargo-credentials | sed 's/.*= *"\(.*\)"/\1/')"
	@echo ""
	@echo "Done. Packages live on PyPI and crates.io."
	@echo ""
	@echo "For automatic CI releases, push .pypirc and .cargo-credentials"
	@echo "as Codeberg repo secrets (Settings > Actions > Secrets):"
	@echo "  PYPI_TOKEN           - the password value from .pypirc"
	@echo "  CARGO_REGISTRY_TOKEN - the token value from .cargo-credentials"
	@echo "  RELEASE_TOKEN        - the token value from .release-token"
	@echo ""
	@echo "Then all future releases: make release V=0.1.1"

# Subsequent releases. Bumps version, commits, tags, pushes.
# CI builds wheels for all platforms and publishes everywhere.
release:
	@test -n "$(V)" || (echo "Usage: make release V=0.1.1" && exit 1)
	sed -i 's/^version = ".*"/version = "$(V)"/' Cargo.toml pyproject.toml
	git add Cargo.toml pyproject.toml
	git commit -m "release v$(V)"
	git tag "v$(V)"
	git push origin main "v$(V)"