Add auto-tagging workflow and update versioning options in pyproject.… #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| lint-and-test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # full history for hatch-vcs | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| run: uv python install ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: uv sync --dev | |
| - name: Lint | |
| run: uv run ruff check src/ tests/ | |
| - name: Test | |
| run: uv run pytest tests/ -v --tb=short | |
| auto-tag: | |
| needs: lint-and-test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Bump patch version and tag | |
| run: | | |
| latest=$(git tag --list 'v*' --sort=-v:refname | head -n1) | |
| if [ -z "$latest" ]; then | |
| next="v0.1.0" | |
| else | |
| # Strip leading 'v', split on '.', bump patch | |
| version="${latest#v}" | |
| major=$(echo "$version" | cut -d. -f1) | |
| minor=$(echo "$version" | cut -d. -f2) | |
| patch=$(echo "$version" | cut -d. -f3) | |
| next="v${major}.${minor}.$((patch + 1))" | |
| fi | |
| echo "Tagging $next" | |
| git tag "$next" | |
| git push origin "$next" |