Upload Python Package #66
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 using Twine when a release is created | |
| name: Upload Python Package | |
| on: | |
| release: | |
| types: [published] | |
| # run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| jobs: | |
| build-all: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| os: [windows-latest, macos-latest, ubuntu-latest, macos-13] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout pyradiance | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: python -m pip install numpy wheel auditwheel build | |
| - name: Build wheels | |
| run: python -m build | |
| - name: Repair wheels with auditwheel (Linux only) | |
| if: runner.os == 'Linux' | |
| run: | | |
| mkdir -p wheelhouse | |
| for whl in dist/*.whl; do | |
| auditwheel repair "$whl" -w wheelhouse/ | |
| done | |
| # Replace original wheels with repaired ones | |
| rm dist/*.whl | |
| cp wheelhouse/*.whl dist/ | |
| - name: upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist-${{ matrix.os }}-python-${{ matrix.python-version }} | |
| path: ./dist/*.whl | |
| if-no-files-found: warn | |
| compression-level: 6 | |
| overwrite: false | |
| include-hidden-files: false | |
| publish-pypi: | |
| runs-on: ubuntu-latest | |
| needs: build-all | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pyradiance | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| strategy: | |
| fail-fast: false | |
| steps: | |
| - name: Download artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: dist-* | |
| path: downloaded_dist | |
| - name: Create dist directory | |
| run: mkdir -p dist | |
| - name: Move wheels to dist directory | |
| run: | | |
| find downloaded_dist -name "*.whl" -exec mv {} dist/ \; | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |