|
| 1 | +name: python |
| 2 | + |
| 3 | +on: [push, pull_request, workflow_dispatch] |
| 4 | + |
| 5 | +env: |
| 6 | + CARGO_TERM_COLOR: always |
| 7 | + |
| 8 | +jobs: |
| 9 | + build_wheels: |
| 10 | + name: build_wheels (os=${{ matrix.os }} target=${{ matrix.target }}) |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - os: ubuntu-24.04 |
| 16 | + target: x86_64 |
| 17 | + cross: false |
| 18 | + - os: macos-15 |
| 19 | + target: universal2 |
| 20 | + cross: false |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: checkout |
| 24 | + uses: actions/checkout@v5 |
| 25 | + - uses: actions/setup-python@v6 |
| 26 | + with: |
| 27 | + python-version: '3.14' |
| 28 | + - uses: dtolnay/rust-toolchain@stable |
| 29 | + - uses: Swatinem/rust-cache@v2 |
| 30 | + - name: build wheel |
| 31 | + uses: PyO3/maturin-action@v1 |
| 32 | + with: |
| 33 | + target: ${{ matrix.target }} |
| 34 | + args: --profile release-lto --out dist |
| 35 | + manylinux: auto |
| 36 | + sccache: true |
| 37 | + - name: delocate wheel (macOS) |
| 38 | + if: runner.os == 'macOS' |
| 39 | + run: | |
| 40 | + pip3 install delocate |
| 41 | + delocate-wheel -v dist/*.whl |
| 42 | + - name: install built wheel |
| 43 | + if: ${{ ! matrix.cross }} |
| 44 | + run: | |
| 45 | + pip3 install miniacd --find-links dist |
| 46 | + python3 -c "import miniacd" |
| 47 | + - name: upload wheels |
| 48 | + uses: actions/upload-artifact@v4 |
| 49 | + with: |
| 50 | + name: wheels-binary-${{ matrix.os }}-${{ matrix.target }} |
| 51 | + path: dist |
| 52 | + - if: github.ref == 'refs/heads/main' |
| 53 | + name: update prerelease tag |
| 54 | + |
| 55 | + with: |
| 56 | + ref: "prerelease" |
| 57 | + |
| 58 | + sdist: |
| 59 | + runs-on: ubuntu-latest |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - name: build sdist |
| 63 | + uses: PyO3/maturin-action@v1 |
| 64 | + with: |
| 65 | + command: sdist |
| 66 | + args: --out dist |
| 67 | + - name: upload sdist |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: wheels-sdist |
| 71 | + path: dist |
| 72 | + |
| 73 | + prerelease: |
| 74 | + if: github.ref == 'refs/heads/main' |
| 75 | + runs-on: ubuntu-latest |
| 76 | + concurrency: |
| 77 | + group: push-${{ github.ref_name }}-prerelease |
| 78 | + cancel-in-progress: true |
| 79 | + needs: [build_wheels, sdist] |
| 80 | + steps: |
| 81 | + - uses: actions/download-artifact@v4 |
| 82 | + with: |
| 83 | + pattern: wheels-* |
| 84 | + merge-multiple: true |
| 85 | + path: wheels |
| 86 | + |
| 87 | + - name: GitHub release |
| 88 | + |
| 89 | + with: |
| 90 | + prerelease: true |
| 91 | + tag: "prerelease" |
| 92 | + name: "Development Build" |
| 93 | + allowUpdates: true |
| 94 | + removeArtifacts: true |
| 95 | + replacesArtifacts: true |
| 96 | + makeLatest: true |
| 97 | + artifacts: "wheels/*" |
| 98 | + |
| 99 | + publish: |
| 100 | + name: publish to PyPI |
| 101 | + runs-on: ubuntu-latest |
| 102 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 103 | + needs: [build_wheels, sdist] |
| 104 | + steps: |
| 105 | + - uses: actions/download-artifact@v4 |
| 106 | + with: |
| 107 | + pattern: wheels-* |
| 108 | + merge-multiple: true |
| 109 | + - uses: PyO3/maturin-action@v1 |
| 110 | + env: |
| 111 | + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 112 | + with: |
| 113 | + command: upload |
| 114 | + args: --non-interactive --skip-existing * |
0 commit comments