fix: CI workflow improvements #1
Workflow file for this run
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
| # REQUIRED: Create a secret for PYPI_TOKEN in the repository settings | |
| # secrets.PYPI_TOKEN: PyPI API token | |
| name: Publish to PyPI | |
| on: | |
| # Deploy to PyPI when a tag is pushed or a release is published | |
| push: | |
| tags: | |
| - 'v*' | |
| release: | |
| types: [published] | |
| jobs: | |
| # Get release version | |
| set-version: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Export tag | |
| id: vars | |
| run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT | |
| - name: Update project version | |
| run: | | |
| sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml | |
| env: | |
| RELEASE_VERSION: ${{ steps.vars.outputs.tag }} | |
| - name: Upload updated pyproject.toml | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyproject-toml | |
| path: pyproject.toml | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: [set-version] | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "0.6.5" | |
| - name: Install Python dependencies | |
| run: uv sync | |
| - name: Download updated pyproject.toml | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pyproject-toml | |
| - name: Build package | |
| run: uv build | |
| - name: Publish package | |
| run: uv publish | |
| env: | |
| UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} |