fix(workflow): update PyPI release commands for clarity and efficiency #70
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: PyPI-Release | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| - v2 | |
| - 'tag/v**' | |
| jobs: | |
| build_dist: | |
| name: Build source distribution | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Install the project | |
| run: uv sync --all-extras --dev | |
| - name: Build SDist and wheel | |
| run: uv build | |
| - uses: actions/upload-artifact@v5 | |
| with: | |
| name: artifact | |
| path: dist/* | |
| - name: Check metadata | |
| run: uvx twine check dist/* | |
| publish: | |
| runs-on: ubuntu-24.04 | |
| if: github.event_name == 'push' | |
| needs: [ build_dist ] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: artifact | |
| path: dist | |
| - name: Publish | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.pypi_password }} | |
| tag: | |
| runs-on: ubuntu-24.04 | |
| needs: [ publish ] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Extract version | |
| id: version | |
| run: | | |
| echo "version=$(grep -oP '__version__ = \"\K[^\"]+' src/cloudevents/__init__.py)" >> $GITHUB_OUTPUT | |
| - name: Create and push tag | |
| uses: pxpm/[email protected] | |
| with: | |
| repo-token: "${{ secrets.GITHUB_TOKEN }}" | |
| tag: ${{ steps.version.outputs.version }} |