|
| 1 | +name: Build, test, and upload to PyPI |
| 2 | + |
| 3 | +# Build on every branch push, tag push, and pull request change: |
| 4 | +on: [push] |
| 5 | + |
| 6 | +jobs: |
| 7 | + build_wheels: |
| 8 | + name: Build wheels on ${{matrix.arch}} for ${{ matrix.os }} |
| 9 | + runs-on: ${{ matrix.os }} |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + os: [ubuntu-20.04, windows-2019, macos-10.15] |
| 13 | + arch: [auto] |
| 14 | + include: |
| 15 | + - os: ubuntu-20.04 |
| 16 | + arch: aarch64 |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v3 |
| 20 | + with: |
| 21 | + submodules: true |
| 22 | + |
| 23 | + - uses: actions/setup-python@v4 |
| 24 | + name: Install Python |
| 25 | + with: |
| 26 | + python-version: '3.7' |
| 27 | + |
| 28 | + - uses: docker/setup-qemu-action@v1 |
| 29 | + if: ${{ matrix.arch == 'aarch64' }} |
| 30 | + name: Set up QEMU |
| 31 | + |
| 32 | + - name: Install cibuildwheel |
| 33 | + run: | |
| 34 | + python -m pip install cibuildwheel |
| 35 | +
|
| 36 | + - name: Build wheels |
| 37 | + run: | |
| 38 | + python -m cibuildwheel --output-dir wheelhouse |
| 39 | + env: |
| 40 | + CIBW_ARCHS_LINUX: ${{matrix.arch}} |
| 41 | + CIBW_ARCHS_MACOS: "x86_64 arm64 universal2" |
| 42 | + CIBW_BEFORE_ALL: "bash -c 'cd \"{project}\"; sh .github/tools/install_yajl.sh'" |
| 43 | + CIBW_BUILD_VERBOSITY: 1 |
| 44 | + CIBW_ENVIRONMENT_MACOS: "IJSON_EMBED_YAJL=1" |
| 45 | + CIBW_ENVIRONMENT_WINDOWS: "IJSON_EMBED_YAJL=1" |
| 46 | + CIBW_TEST_COMMAND: "bash -c 'cd \"{project}\"; pytest -vv'" |
| 47 | + CIBW_TEST_REQUIRES: pytest cffi |
| 48 | + |
| 49 | + - uses: actions/upload-artifact@v3 |
| 50 | + with: |
| 51 | + path: ./wheelhouse/*.whl |
| 52 | + |
| 53 | + build_sdist: |
| 54 | + name: Build source distribution |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v3 |
| 58 | + |
| 59 | + - uses: actions/setup-python@v4 |
| 60 | + name: Install Python |
| 61 | + with: |
| 62 | + python-version: '3.7' |
| 63 | + |
| 64 | + - name: Build sdist |
| 65 | + run: python setup.py sdist |
| 66 | + |
| 67 | + - uses: actions/upload-artifact@v3 |
| 68 | + with: |
| 69 | + path: dist/*.tar.gz |
| 70 | + |
| 71 | + upload_pypi: |
| 72 | + needs: [build_wheels, build_sdist] |
| 73 | + runs-on: ubuntu-latest |
| 74 | + if: startsWith(github.event.ref, 'refs/tags/v') |
| 75 | + steps: |
| 76 | + - uses: actions/download-artifact@v3 |
| 77 | + with: |
| 78 | + name: artifact |
| 79 | + path: dist |
| 80 | + |
| 81 | + - uses: pypa/gh-action-pypi-publish@master |
| 82 | + with: |
| 83 | + user: __token__ |
| 84 | + password: ${{ secrets.pypi_password }} |
0 commit comments