feat: Add GitHub releases and semantic versioning #1
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: Release | |
| on: | |
| push: | |
| branches: [main] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| enable-cache: true | |
| cache-dependency-glob: "pyproject.toml" | |
| ignore-nothing-to-cache: true | |
| - name: Set up Python | |
| run: uv python install 3.9 | |
| - name: Install dependencies | |
| run: uv sync --group dev | |
| - name: Run tests | |
| run: uv run pytest tests/ -v --tb=short | |
| - name: Run semantic-release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: uv run semantic-release publish --ci | |
| - name: Build distribution packages | |
| run: uv run pip install build && python -m build | |
| - name: Upload artifacts to release | |
| if: github.ref == 'refs/heads/main' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Get the latest tag | |
| LATEST_TAG=$(git describe --tags --abbrev=0 || echo "") | |
| if [ -n "$LATEST_TAG" ]; then | |
| # Upload wheel and sdist to the release | |
| gh release upload "$LATEST_TAG" dist/*.whl dist/*.tar.gz --clobber | |
| fi | |