Upload Python Package #53
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
| # This workflow will upload a Python Package to PyPI when a release is created | |
| # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries | |
| # This workflow uses actions that are not certified by GitHub. | |
| # They are provided by a third-party and are governed by | |
| # separate terms of service, privacy policy, and support | |
| # documentation. | |
| name: Upload Python Package | |
| on: | |
| workflow_dispatch: | |
| release: | |
| types: [published] | |
| permissions: | |
| contents: write | |
| jobs: | |
| release-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup and Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| version: "0.6.4" | |
| - name: Set up Python | |
| run: uv python install | |
| - name: Create and activate virtual environment | |
| run: | | |
| uv venv | |
| source .venv/bin/activate | |
| uv pip install bump-my-version | |
| - name: Bump version | |
| id: bump | |
| working-directory: . | |
| run: | | |
| source .venv/bin/activate | |
| bump-my-version bump patch --allow-dirty | |
| NEW_VERSION=$(bump-my-version show current_version) | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Commit and push new version | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add pyproject.toml .bumpversion.toml | |
| git commit -m "Bump version to ${{ steps.bump.outputs.new_version }}" | |
| git tag v${{ steps.bump.outputs.new_version }} | |
| git push | |
| git push --tags | |
| - name: Make build | |
| run: | | |
| uv sync | |
| uv build | |
| - name: pypi-publish | |
| uses: pypa/gh-action-pypi-publish@v1.12.3 | |
| with: | |
| password: ${{ secrets.pypi_token }} | |
| skip-existing: false | |
| verbose: true |