|
| 1 | +name: Test & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + sdist: |
| 16 | + name: Build sdist |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + - uses: actions/setup-python@v2 |
| 21 | + name: Install Python |
| 22 | + with: |
| 23 | + python-version: '3.7' |
| 24 | + - name: Install deps |
| 25 | + run: pip install -U maturin |
| 26 | + - name: Build sdist |
| 27 | + run: maturin build --release --strip |
| 28 | + - uses: actions/upload-artifact@v2 |
| 29 | + with: |
| 30 | + path: ./target/wheels/*.tar.gz |
| 31 | + name: dist |
| 32 | + build_wheels: |
| 33 | + name: Build wheels on ${{ matrix.os }} / Python ${{ matrix.python }} |
| 34 | + runs-on: ${{ matrix.os }} |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + os: [ubuntu-latest, windows-latest, macos-latest] |
| 39 | + # For CPython only build 3.7 since we use the abi3 limited API |
| 40 | + # For PyPy, build all versions |
| 41 | + python: ["3.7", "pypy-3.7", "pypy-3.8"] |
| 42 | + include: |
| 43 | + - python: "pypy-3.7" |
| 44 | + cibw_build: "pp37*" |
| 45 | + - python: "pypy-3.8" |
| 46 | + cibw_build: "pp38*" |
| 47 | + - python: "3.7" |
| 48 | + cibw_build: "cp37-*" |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v2 |
| 51 | + - uses: actions/setup-python@v2 |
| 52 | + with: |
| 53 | + python-version: ${{ matrix.python }} |
| 54 | + - uses: actions-rs/toolchain@v1 |
| 55 | + if: runner.os != 'Linux' |
| 56 | + with: |
| 57 | + toolchain: stable |
| 58 | + profile: minimal |
| 59 | + - name: Set up QEMU |
| 60 | + if: runner.os == 'Linux' |
| 61 | + uses: docker/setup-qemu-action@v1 |
| 62 | + with: |
| 63 | + platforms: all |
| 64 | + - name: Install cibuildwheel |
| 65 | + run: | |
| 66 | + python -m pip install cibuildwheel |
| 67 | + - name: Build wheels |
| 68 | + run: | |
| 69 | + python -m cibuildwheel --output-dir wheelhouse |
| 70 | + env: |
| 71 | + CIBW_BEFORE_BUILD: "pip install -r requirements-dev.txt" |
| 72 | + CIBW_BEFORE_TEST: "pip install -r requirements-dev.txt" |
| 73 | + CIBW_TEST_COMMAND: "pytest {project}/test_routrie.py" |
| 74 | + # Install curl on manylinux_2 images (others have it) and then install cargo and rust |
| 75 | + CIBW_BEFORE_ALL_LINUX: "((apt-get update && apt-get install curl || true) && (curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable)) || apk add rust cargo" |
| 76 | + CIBW_TEST_SKIP: "*-macosx_arm64 *-macosx_universal2:arm64" |
| 77 | + CIBW_BUILD: ${{ matrix.cibw_build }} |
| 78 | + CIBW_SKIP: "*-win32*" |
| 79 | + CIBW_ENVIRONMENT_LINUX: 'PATH="$PATH:$HOME/.cargo/bin"' |
| 80 | + # Cross compile on MacOS and Linux |
| 81 | + CIBW_ARCHS_MACOS: "auto universal2 arm64" |
| 82 | + CIBW_ARCHS_LINUX: "auto aarch64" |
| 83 | + - uses: actions/upload-artifact@v2 |
| 84 | + with: |
| 85 | + name: dist |
| 86 | + path: ./wheelhouse/*.whl |
| 87 | + lint: |
| 88 | + runs-on: ubuntu-latest |
| 89 | + strategy: |
| 90 | + matrix: |
| 91 | + # Lint on earliest and latest |
| 92 | + python: ["3.7", "3.x"] |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@v2 |
| 95 | + - name: Set up Python |
| 96 | + uses: actions/setup-python@v2 |
| 97 | + with: |
| 98 | + python-version: '3.x' |
| 99 | + - name: Install Rust toolchain |
| 100 | + uses: actions-rs/toolchain@v1 |
| 101 | + with: |
| 102 | + toolchain: stable |
| 103 | + profile: minimal |
| 104 | + default: true |
| 105 | + - name: Lint |
| 106 | + run: | |
| 107 | + make lint |
| 108 | + release: |
| 109 | + name: Release |
| 110 | + runs-on: ubuntu-latest |
| 111 | + if: ${{ github.ref == 'refs/heads/main' }} |
| 112 | + needs: |
| 113 | + - sdist |
| 114 | + - build_wheels |
| 115 | + - lint |
| 116 | + steps: |
| 117 | + - uses: actions/download-artifact@v2 |
| 118 | + with: |
| 119 | + name: dist |
| 120 | + - uses: actions/setup-python@v2 |
| 121 | + with: |
| 122 | + python-version: "3.x" |
| 123 | + - name: Publish to PyPi |
| 124 | + env: |
| 125 | + TWINE_USERNAME: __token__ |
| 126 | + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 127 | + run: | |
| 128 | + pip install --upgrade twine pip |
| 129 | + twine upload --skip-existing * |
0 commit comments