[maint] Test wheels to check that they work fine #103
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: Build wheels | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| paths: | |
| - "**" | |
| - "!**.md" | |
| - "!**.rst" | |
| - "!docs/**" | |
| - "!test_*.py" | |
| - "!tests/**" | |
| - "!.github/workflows/*.yml" | |
| - ".github/workflows/wheels.yml" | |
| push: | |
| branches: | |
| - main | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| build_wheels: | |
| name: Build linux wheels | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Install CUDA | |
| uses: Jimver/cuda-toolkit@v0.2.25 | |
| id: cuda-toolkit | |
| with: | |
| method: "network" | |
| sub-packages: '["nvcc"]' | |
| - name: CUDA diagnostic info | |
| run: | | |
| nvcc --version | |
| - uses: pypa/cibuildwheel@v2.23 | |
| - name: Verify clean directory | |
| run: git diff --exit-code | |
| shell: bash | |
| - name: Upload wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: wheelhouse/*.whl | |
| name: dist-linux-wheels | |
| test_wheels: | |
| name: Test wheel import | |
| needs: [build_wheels] | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: dist-linux-wheels | |
| path: wheelhouse | |
| - name: Install wheel | |
| run: | | |
| PYTHON_VERSION_NO_DOT=$(echo "${{ matrix.python-version }}" | tr -d '.') | |
| pip install wheelhouse/mach_beamform-*-cp${PYTHON_VERSION_NO_DOT}-*.whl | |
| - name: Test import mach | |
| run: python -c 'import mach; print(mach.__version__)' | |
| upload_all: | |
| name: Upload if release | |
| needs: [test_wheels] | |
| runs-on: ubuntu-22.04 | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| # not using uv for caching, just publish, so workdir is empty | |
| ignore-empty-workdir: true | |
| # and cache is disabled | |
| enable-cache: false | |
| - name: Download wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: dist-* | |
| merge-multiple: true | |
| - name: Upload wheels to the GitHub Release that triggered this workflow | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/*.whl | |
| - name: Publish to PyPI | |
| run: uv publish | |
| # https://docs.pypi.org/trusted-publishers/adding-a-publisher/ | |
| smoke_test: | |
| name: check PyPI release | |
| needs: [upload_all] | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| matrix: | |
| python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| ignore-empty-workdir: true | |
| enable-cache: false | |
| - name: Test import mach | |
| run: uvx --with mach-beamform --python ${{ matrix.python-version }} python -c 'import mach; print(mach.__version__)' |