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
| # This workflow uploads a Python Package to PyPI when a release is published. | |
| # Uses OIDC Trusted Publishing (no API tokens needed). | |
| # For setup instructions: https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
| # | |
| # IMPORTANT: On PyPI, the Trusted Publisher must be configured with: | |
| # - Owner: radis | |
| # - Repository: radis | |
| # - Workflow: publish-Pypi.yml | |
| # - Environment: pypi-deploy | |
| name: Upload Python Package to PyPI | |
| on: | |
| release: | |
| types: [published] | |
| # WARNING: merge to master BEFORE creating the release | |
| permissions: | |
| contents: read | |
| jobs: | |
| release-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Validate release tag matches package version in radis/__version__.txt | |
| run: | | |
| PKG_VERSION=$(cat radis/__version__.txt | tr -d '[:space:]') | |
| TAG_VERSION="${{ github.event.release.tag_name }}" | |
| # Strip leading 'v' from tag if present (e.g. v0.16.4 -> 0.16.4) | |
| TAG_VERSION="${TAG_VERSION#v}" | |
| echo "Package version: $PKG_VERSION" | |
| echo "Release tag: $TAG_VERSION" | |
| if [ "$PKG_VERSION" != "$TAG_VERSION" ]; then | |
| echo "ERROR: Tag '$TAG_VERSION' does not match radis/__version__.txt '$PKG_VERSION'" | |
| echo "Bump the version in radis/__version__.txt before releasing." | |
| exit 1 | |
| fi | |
| - name: Build release distributions | |
| run: | | |
| python -m pip install build | |
| python -m build --sdist --wheel | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| pypi-publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - release-build | |
| permissions: | |
| id-token: write # required for OIDC Trusted Publishing | |
| environment: | |
| name: pypi-deploy | |
| url: https://pypi.org/project/radis/ | |
| steps: | |
| - name: Retrieve release distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: release-dists | |
| path: dist/ | |
| - name: Publish release distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist/ | |
| skip-existing: true | |
| verbose: true |