|
| 1 | +name: Python package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + macos: |
| 9 | + runs-on: macos-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v3 |
| 12 | + - uses: actions/setup-python@v4 |
| 13 | + with: |
| 14 | + python-version: 3.9 |
| 15 | + architecture: x64 |
| 16 | + - uses: dtolnay/rust-toolchain@stable |
| 17 | + - name: Build wheels - x86_64 |
| 18 | + uses: PyO3/maturin-action@v1 |
| 19 | + with: |
| 20 | + target: x86_64 |
| 21 | + args: --release --out dist --sdist -m wonnx-py/Cargo.toml |
| 22 | + - name: Install built wheel - x86_64 |
| 23 | + run: | |
| 24 | + pip install wonnx --no-index --find-links dist --force-reinstall |
| 25 | + python -c "import wonnx" |
| 26 | + - name: Build wheels - universal2 |
| 27 | + uses: PyO3/maturin-action@v1 |
| 28 | + with: |
| 29 | + args: --release --universal2 --out dist -m wonnx-py/Cargo.toml |
| 30 | + - name: Install built wheel - universal2 |
| 31 | + run: | |
| 32 | + pip install wonnx --no-index --find-links dist --force-reinstall |
| 33 | + python -c "import wonnx" |
| 34 | + - name: Upload wheels |
| 35 | + uses: actions/upload-artifact@v3 |
| 36 | + with: |
| 37 | + name: wheels |
| 38 | + path: dist |
| 39 | + |
| 40 | + windows: |
| 41 | + runs-on: windows-latest |
| 42 | + strategy: |
| 43 | + matrix: |
| 44 | + target: [x64, x86] |
| 45 | + steps: |
| 46 | + - uses: actions/checkout@v3 |
| 47 | + - uses: actions/setup-python@v4 |
| 48 | + with: |
| 49 | + python-version: 3.9 |
| 50 | + architecture: ${{ matrix.target }} |
| 51 | + - uses: dtolnay/rust-toolchain@stable |
| 52 | + - name: Build wheels |
| 53 | + uses: PyO3/maturin-action@v1 |
| 54 | + with: |
| 55 | + target: ${{ matrix.target }} |
| 56 | + args: --release --out dist -m wonnx-py/Cargo.toml |
| 57 | + - name: Install built wheel |
| 58 | + run: | |
| 59 | + pip install wonnx --no-index --find-links dist --force-reinstall |
| 60 | + python -c "import wonnx" |
| 61 | + - name: Upload wheels |
| 62 | + uses: actions/upload-artifact@v3 |
| 63 | + with: |
| 64 | + name: wheels |
| 65 | + path: dist |
| 66 | + |
| 67 | + linux: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + strategy: |
| 70 | + matrix: |
| 71 | + target: [x86_64, i686] |
| 72 | + steps: |
| 73 | + - uses: actions/checkout@v3 |
| 74 | + - uses: actions/setup-python@v4 |
| 75 | + with: |
| 76 | + python-version: 3.9 |
| 77 | + architecture: x64 |
| 78 | + - name: Build wheels |
| 79 | + uses: PyO3/maturin-action@v1 |
| 80 | + with: |
| 81 | + target: ${{ matrix.target }} |
| 82 | + manylinux: auto |
| 83 | + args: --release --out dist -m wonnx-py/Cargo.toml |
| 84 | + - name: Install built wheel |
| 85 | + if: matrix.target == 'x86_64' |
| 86 | + run: | |
| 87 | + pip install wonnx --no-index --find-links dist --force-reinstall |
| 88 | + python -c "import wonnx" |
| 89 | + - name: Upload wheels |
| 90 | + uses: actions/upload-artifact@v3 |
| 91 | + with: |
| 92 | + name: wheels |
| 93 | + path: dist |
| 94 | + |
| 95 | + linux-cross: |
| 96 | + runs-on: ubuntu-latest |
| 97 | + strategy: |
| 98 | + matrix: |
| 99 | + target: [aarch64, armv7, s390x, ppc64le, ppc64] |
| 100 | + steps: |
| 101 | + - uses: actions/checkout@v3 |
| 102 | + - uses: actions/setup-python@v4 |
| 103 | + with: |
| 104 | + python-version: 3.9 |
| 105 | + - name: Build wheels |
| 106 | + uses: PyO3/maturin-action@v1 |
| 107 | + with: |
| 108 | + target: ${{ matrix.target }} |
| 109 | + manylinux: auto |
| 110 | + args: --release --out dist -m wonnx-py/Cargo.toml |
| 111 | + |
| 112 | + if: matrix.target != 'ppc64' |
| 113 | + name: Install built wheel |
| 114 | + with: |
| 115 | + arch: ${{ matrix.target }} |
| 116 | + distro: ubuntu20.04 |
| 117 | + githubToken: ${{ github.token }} |
| 118 | + install: | |
| 119 | + apt-get update |
| 120 | + apt-get install -y --no-install-recommends python3 python3-pip |
| 121 | + pip3 install -U pip |
| 122 | + run: | |
| 123 | + pip3 install wonnx --no-index --find-links dist/ --force-reinstall |
| 124 | + python3 -c "import wonnx" |
| 125 | + - name: Upload wheels |
| 126 | + uses: actions/upload-artifact@v3 |
| 127 | + with: |
| 128 | + name: wheels |
| 129 | + path: dist |
| 130 | + |
| 131 | + musllinux: |
| 132 | + runs-on: ubuntu-latest |
| 133 | + strategy: |
| 134 | + matrix: |
| 135 | + target: |
| 136 | + - x86_64-unknown-linux-musl |
| 137 | + - i686-unknown-linux-musl |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v3 |
| 140 | + - uses: actions/setup-python@v4 |
| 141 | + with: |
| 142 | + python-version: 3.9 |
| 143 | + architecture: x64 |
| 144 | + - name: Build wheels |
| 145 | + uses: PyO3/maturin-action@v1 |
| 146 | + with: |
| 147 | + target: ${{ matrix.target }} |
| 148 | + manylinux: musllinux_1_2 |
| 149 | + args: --release --out dist -m wonnx-py/Cargo.toml |
| 150 | + - name: Install built wheel |
| 151 | + if: matrix.target == 'x86_64-unknown-linux-musl' |
| 152 | + uses: addnab/docker-run-action@v3 |
| 153 | + with: |
| 154 | + image: alpine:latest |
| 155 | + options: -v ${{ github.workspace }}:/io -w /io |
| 156 | + run: | |
| 157 | + apk add py3-pip |
| 158 | + pip3 install -U pip |
| 159 | + pip3 install wonnx --no-index --find-links /io/dist/ --force-reinstall |
| 160 | + python3 -c "import wonnx" |
| 161 | + - name: Upload wheels |
| 162 | + uses: actions/upload-artifact@v3 |
| 163 | + with: |
| 164 | + name: wheels |
| 165 | + path: dist |
| 166 | + |
| 167 | + musllinux-cross: |
| 168 | + runs-on: ubuntu-latest |
| 169 | + strategy: |
| 170 | + matrix: |
| 171 | + platform: |
| 172 | + - target: aarch64-unknown-linux-musl |
| 173 | + arch: aarch64 |
| 174 | + - target: armv7-unknown-linux-musleabihf |
| 175 | + arch: armv7 |
| 176 | + steps: |
| 177 | + - uses: actions/checkout@v3 |
| 178 | + - uses: actions/setup-python@v4 |
| 179 | + with: |
| 180 | + python-version: 3.9 |
| 181 | + - name: Build wheels |
| 182 | + uses: PyO3/maturin-action@v1 |
| 183 | + with: |
| 184 | + target: ${{ matrix.platform.target }} |
| 185 | + manylinux: musllinux_1_2 |
| 186 | + args: --release --out dist -m wonnx-py/Cargo.toml |
| 187 | + |
| 188 | + name: Install built wheel |
| 189 | + with: |
| 190 | + arch: ${{ matrix.platform.arch }} |
| 191 | + distro: alpine_latest |
| 192 | + githubToken: ${{ github.token }} |
| 193 | + install: | |
| 194 | + apk add py3-pip |
| 195 | + pip3 install -U pip |
| 196 | + run: | |
| 197 | + pip3 install wonnx --no-index --find-links dist/ --force-reinstall |
| 198 | + python3 -c "import wonnx" |
| 199 | + - name: Upload wheels |
| 200 | + uses: actions/upload-artifact@v3 |
| 201 | + with: |
| 202 | + name: wheels |
| 203 | + path: dist |
| 204 | + |
| 205 | + release: |
| 206 | + name: Release |
| 207 | + runs-on: ubuntu-latest |
| 208 | + if: "startsWith(github.ref, 'refs/tags/')" |
| 209 | + needs: [macos, windows, linux, linux-cross, musllinux, musllinux-cross] |
| 210 | + steps: |
| 211 | + - uses: actions/download-artifact@v3 |
| 212 | + with: |
| 213 | + name: wheels |
| 214 | + - uses: actions/setup-python@v4 |
| 215 | + with: |
| 216 | + python-version: 3.9 |
| 217 | + - name: Publish to PyPI |
| 218 | + env: |
| 219 | + TWINE_USERNAME: __token__ |
| 220 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASS }} |
| 221 | + run: | |
| 222 | + pip install --upgrade twine |
| 223 | + twine upload --skip-existing * |
0 commit comments