Publish Python package on version tags #1
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 package | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| name: Build Python package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install build tools | |
| run: python -m pip install --upgrade pip build twine | |
| - name: Build distributions | |
| run: python -m build Python/rd2d | |
| - name: Check distributions | |
| run: python -m twine check Python/rd2d/dist/* | |
| - name: Upload distributions | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: Python/rd2d/dist/* | |
| if-no-files-found: error | |
| test: | |
| name: Test Python package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install package | |
| run: python -m pip install -e "Python/rd2d[test,plots]" | |
| - name: Run tests | |
| working-directory: Python/rd2d | |
| run: python -m pytest | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build, test] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/rd2d/ | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download distributions | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: python-dist | |
| path: dist | |
| - name: Publish distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist |