Publish Python Distribution to PyPI #5
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
| name: Publish Python Distribution to PyPI | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| jobs: | |
| build: | |
| name: Build Python Distribution 📦 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" # Use the latest stable Python 3 version | |
| - name: Upgrade pip and install build tools | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y build-essential | |
| python -m pip install --upgrade pip | |
| pip install build wheel setuptools | |
| - name: Build package | |
| run: python -m build | |
| - name: Upload built distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-pypi: | |
| name: Publish to PyPI 🚀 | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download built distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| github-release: | |
| name: Create GitHub Release 🏷️ | |
| needs: publish-to-pypi | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download built distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |