next_version := `git-cliff --bumped-version`

create-changelog:
    git-cliff --bump -o CHANGELOG.md

release: create-changelog
    awk -i inplace '{ sub(/^version = "[0-9]+\.[0-9]+\.[0-9]+"/, "version = \"{{next_version}}\"") }; { print }' pyproject.toml
    awk -i inplace '{ sub(/^__version__ = "[0-9]+\.[0-9]+\.[0-9]+"/, "__version__ = \"{{next_version}}\"") }; { print }' brainlessdb/__init__.py
    git add --ignore-errors CHANGELOG.md pyproject.toml uv.lock brainlessdb/__init__.py
    git commit -m {{next_version}}
    git tag -a {{next_version}} -m {{next_version}}

push:
    git push
    git push --tags

publish:
    rm dist/* || exit 0
    uv build
    uv publish

install:
    uv sync

test *args:
    uv run pytest tests/ {{args}}

lint:
    uv run ruff check .
    uv run ruff format --check .

format:
    uv run ruff check --fix .
    uv run ruff format .

clean:
    find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
    find . -type f -name "*.pyc" -delete
