|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ["v*"] |
| 6 | + pull_request: |
| 7 | + paths-ignore: |
| 8 | + - "docs/**" |
| 9 | + - "**.md" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +jobs: |
| 13 | + build_wheels: |
| 14 | + name: Wheel (${{ matrix.os }}) |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [ubuntu-22.04, macos-13] |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + # Build wheels using cibuildwheel |
| 25 | + # ENV variables control the build (architectures, python versions) |
| 26 | + - name: Build wheels |
| 27 | + uses: pypa/cibuildwheel@v2.21.3 |
| 28 | + env: |
| 29 | + # Build for Python 3.9+ |
| 30 | + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" |
| 31 | + # Skip PyPy and musllinux for now (unless desired) |
| 32 | + CIBW_SKIP: "pp* *-musllinux_*" |
| 33 | + |
| 34 | + # macOS: Build Universal2 wheels on Intel runner (macos-13) |
| 35 | + CIBW_ARCHS_MACOS: "universal2" |
| 36 | + CIBW_TEST_COMMAND: "python -c \"import netgraph_core; print(netgraph_core.__version__)\"" |
| 37 | + |
| 38 | + - uses: actions/upload-artifact@v4 |
| 39 | + with: |
| 40 | + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} |
| 41 | + path: ./wheelhouse/*.whl |
| 42 | + |
| 43 | + build_sdist: |
| 44 | + name: Build SDist |
| 45 | + runs-on: ubuntu-latest |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Build SDist |
| 50 | + run: pipx run build --sdist |
| 51 | + |
| 52 | + - uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: cibw-sdist |
| 55 | + path: dist/*.tar.gz |
| 56 | + |
| 57 | + publish_pypi: |
| 58 | + name: Publish to PyPI |
| 59 | + needs: [build_wheels, build_sdist] |
| 60 | + runs-on: ubuntu-latest |
| 61 | + environment: pypi |
| 62 | + permissions: |
| 63 | + id-token: write # Required for Trusted Publishing (OIDC) |
| 64 | + |
| 65 | + # Only publish on tag pushes |
| 66 | + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') |
| 67 | + |
| 68 | + steps: |
| 69 | + - uses: actions/download-artifact@v4 |
| 70 | + with: |
| 71 | + pattern: cibw-* |
| 72 | + path: dist |
| 73 | + merge-multiple: true |
| 74 | + |
| 75 | + - name: Publish to PyPI |
| 76 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments