|
| 1 | +# Build + test, then on a version tag (`vX.Y.Z`): attach wheels + sdist to a GitHub Release and publish |
| 2 | +# the crate to crates.io. (No PyPI — install the Python package from a release wheel or via |
| 3 | +# `pip install git+https://github.com/prostomarkeloff/difflib-fast`.) |
| 4 | +# |
| 5 | +# Required repository secret for the release: |
| 6 | +# CARGO_REGISTRY_TOKEN — a crates.io API token (the GitHub Release uses the built-in GITHUB_TOKEN) |
| 7 | +# |
| 8 | +# abi3 (pyo3 abi3-py39) → one wheel per platform/arch works on CPython 3.9+, so no per-Python matrix. |
| 9 | +name: CI |
| 10 | + |
| 11 | +on: |
| 12 | + push: |
| 13 | + branches: [main] |
| 14 | + tags: ["v*"] |
| 15 | + pull_request: |
| 16 | + workflow_dispatch: |
| 17 | + |
| 18 | +permissions: |
| 19 | + contents: read |
| 20 | + |
| 21 | +jobs: |
| 22 | + test: |
| 23 | + name: test + clippy |
| 24 | + runs-on: ubuntu-latest |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - uses: dtolnay/rust-toolchain@stable |
| 28 | + with: |
| 29 | + components: clippy |
| 30 | + - run: cargo test --release |
| 31 | + - run: cargo clippy --release --all-targets --features bench |
| 32 | + |
| 33 | + linux: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + strategy: |
| 36 | + matrix: |
| 37 | + target: [x86_64, aarch64] |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v4 |
| 40 | + - uses: actions/setup-python@v5 |
| 41 | + with: |
| 42 | + python-version: "3.12" |
| 43 | + - name: Build wheels |
| 44 | + uses: PyO3/maturin-action@v1 |
| 45 | + with: |
| 46 | + target: ${{ matrix.target }} |
| 47 | + args: --release --out dist |
| 48 | + sccache: "true" |
| 49 | + manylinux: auto |
| 50 | + - uses: actions/upload-artifact@v4 |
| 51 | + with: |
| 52 | + name: wheels-linux-${{ matrix.target }} |
| 53 | + path: dist |
| 54 | + |
| 55 | + macos: |
| 56 | + runs-on: macos-latest |
| 57 | + strategy: |
| 58 | + matrix: |
| 59 | + target: [x86_64, aarch64] |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@v4 |
| 62 | + - uses: actions/setup-python@v5 |
| 63 | + with: |
| 64 | + python-version: "3.12" |
| 65 | + - name: Build wheels |
| 66 | + uses: PyO3/maturin-action@v1 |
| 67 | + with: |
| 68 | + target: ${{ matrix.target }} |
| 69 | + args: --release --out dist |
| 70 | + sccache: "true" |
| 71 | + - uses: actions/upload-artifact@v4 |
| 72 | + with: |
| 73 | + name: wheels-macos-${{ matrix.target }} |
| 74 | + path: dist |
| 75 | + |
| 76 | + windows: |
| 77 | + runs-on: windows-latest |
| 78 | + steps: |
| 79 | + - uses: actions/checkout@v4 |
| 80 | + - uses: actions/setup-python@v5 |
| 81 | + with: |
| 82 | + python-version: "3.12" |
| 83 | + - name: Build wheels |
| 84 | + uses: PyO3/maturin-action@v1 |
| 85 | + with: |
| 86 | + target: x64 |
| 87 | + args: --release --out dist |
| 88 | + sccache: "true" |
| 89 | + - uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: wheels-windows |
| 92 | + path: dist |
| 93 | + |
| 94 | + sdist: |
| 95 | + runs-on: ubuntu-latest |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v4 |
| 98 | + - name: Build sdist |
| 99 | + uses: PyO3/maturin-action@v1 |
| 100 | + with: |
| 101 | + command: sdist |
| 102 | + args: --out dist |
| 103 | + - uses: actions/upload-artifact@v4 |
| 104 | + with: |
| 105 | + name: wheels-sdist |
| 106 | + path: dist |
| 107 | + |
| 108 | + release: |
| 109 | + name: GitHub release (wheels + sdist) |
| 110 | + runs-on: ubuntu-latest |
| 111 | + if: startsWith(github.ref, 'refs/tags/') |
| 112 | + needs: [test, linux, macos, windows, sdist] |
| 113 | + permissions: |
| 114 | + contents: write |
| 115 | + steps: |
| 116 | + - uses: actions/download-artifact@v4 |
| 117 | + with: |
| 118 | + path: dist |
| 119 | + pattern: wheels-* |
| 120 | + merge-multiple: true |
| 121 | + - name: Attach wheels + sdist to the release |
| 122 | + uses: softprops/action-gh-release@v2 |
| 123 | + with: |
| 124 | + files: dist/* |
| 125 | + |
| 126 | + crates: |
| 127 | + name: publish to crates.io |
| 128 | + runs-on: ubuntu-latest |
| 129 | + if: startsWith(github.ref, 'refs/tags/') |
| 130 | + needs: [test] |
| 131 | + steps: |
| 132 | + - uses: actions/checkout@v4 |
| 133 | + - uses: dtolnay/rust-toolchain@stable |
| 134 | + - run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }} |
0 commit comments