Initial Release #3
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: Bump version and publish to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| bump-version-and-publish: | |
| name: Update version and publish to PyPI | |
| runs-on: ubuntu-latest | |
| environment: PyPi | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Extract version from tag | |
| id: extract_version | |
| run: | | |
| echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Update pyproject.toml and conf.py | |
| run: | | |
| VERSION=${{ steps.extract_version.outputs.VERSION }} | |
| echo "🔧 Setting version to $VERSION" | |
| # Update pyproject.toml | |
| sed -i "s/^version = \".*\"/version = \"$VERSION\"/" pyproject.toml | |
| # Update Sphinx docs/conf.py (or wherever your conf.py is) | |
| sed -i "s/^release = \".*\"/release = \"$VERSION\"/" docs/source/conf.py | |
| sed -i "s/^version = \".*\"/version = \"${VERSION%.*}\"/" docs/source/conf.py # Major.minor | |
| - name: Commit version updates | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.github.com" | |
| git commit -am "Bump version to ${{ steps.extract_version.outputs.VERSION }}" | |
| git push | |
| - name: Install build tools | |
| run: | | |
| pip install --upgrade pip | |
| pip install build twine | |
| - name: Build the package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: python -m twine upload dist/* |