|
| 1 | +# Workflow to build and test wheels |
| 2 | +name: Wheel builder |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + # Release branches |
| 9 | + - "[0-9]+.[0-9]+.X" |
| 10 | + |
| 11 | +jobs: |
| 12 | + # Build the wheels for Linux |
| 13 | + build_wheels: |
| 14 | + name: Build wheel for cp${{ matrix.python }}-${{ matrix.platform_id }}-${{ matrix.manylinux_image }} |
| 15 | + runs-on: ${{ matrix.os }} |
| 16 | + |
| 17 | + strategy: |
| 18 | + # Ensure that a wheel builder finishes even if another fails |
| 19 | + fail-fast: false |
| 20 | + matrix: |
| 21 | + os: [ubuntu-latest] |
| 22 | + python: [36, 37, 38, 39] |
| 23 | + bitness: [32, 64] |
| 24 | + manylinux_image: [manylinux2014] |
| 25 | + include: |
| 26 | + - os: ubuntu-latest |
| 27 | + bitness: 64 |
| 28 | + platform_id: manylinux_x86_64 |
| 29 | + - os: ubuntu-latest |
| 30 | + bitness: 32 |
| 31 | + platform_id: manylinux_i686 |
| 32 | + |
| 33 | + steps: |
| 34 | + - name: Checkout pyrfr |
| 35 | + uses: actions/checkout@v1 |
| 36 | + |
| 37 | + - name: Setup Python |
| 38 | + uses: actions/setup-python@v2 |
| 39 | + |
| 40 | + - name: Build and test wheels |
| 41 | + env: |
| 42 | + CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} |
| 43 | + CIBW_MANYLINUX_X86_64_IMAGE: ${{ matrix.manylinux_image }} |
| 44 | + CIBW_MANYLINUX_I686_IMAGE: ${{ matrix.manylinux_image }} |
| 45 | + CIBW_TEST_REQUIRES: pytest threadpoolctl numpy<=1.19 |
| 46 | + CIBW_BEFORE_ALL: "{project}/build_tools/build_wheels.sh" |
| 47 | + CIBW_TEST_COMMAND: bash {project}/build_tools/test_wheels.sh |
| 48 | + |
| 49 | + run: | |
| 50 | + python -m pip install cibuildwheel |
| 51 | + python -m cibuildwheel --output-dir wheelhouse |
| 52 | +
|
| 53 | + - name: Store artifacts |
| 54 | + uses: actions/upload-artifact@v2 |
| 55 | + with: |
| 56 | + path: wheelhouse/*.whl |
| 57 | + |
| 58 | + # Build the source distribution under Linux |
| 59 | + build_sdist: |
| 60 | + name: Source distribution |
| 61 | + runs-on: ubuntu-latest |
| 62 | + |
| 63 | + steps: |
| 64 | + - name: Checkout pyrfr |
| 65 | + uses: actions/checkout@v1 |
| 66 | + |
| 67 | + - name: Setup Python |
| 68 | + uses: actions/setup-python@v2 |
| 69 | + |
| 70 | + - name: Build source distribution |
| 71 | + run: bash build_tools/build_source.sh |
| 72 | + |
| 73 | + - name: Test source distribution |
| 74 | + run: bash build_tools/test_source.sh |
| 75 | + |
| 76 | + - name: Store artifacts |
| 77 | + uses: actions/upload-artifact@v2 |
| 78 | + with: |
| 79 | + path: dist/*.tar.gz |
| 80 | + |
| 81 | + # Upload the wheels and the source distribution |
| 82 | + release_assets: |
| 83 | + name: Upload Release |
| 84 | + runs-on: ubuntu-latest |
| 85 | + needs: [build_wheels, build_sdist] |
| 86 | + # The artifacts cannot be uploaded on PRs |
| 87 | + if: github.event_name != 'pull_request' |
| 88 | + |
| 89 | + steps: |
| 90 | + - name: Checkout pyrfr |
| 91 | + uses: actions/checkout@v1 |
| 92 | + |
| 93 | + - name: Download artifacts |
| 94 | + uses: actions/download-artifact@v2 |
| 95 | + with: |
| 96 | + path: dist |
| 97 | + |
| 98 | + - name: Setup Python |
| 99 | + uses: actions/setup-python@v2 |
| 100 | + |
| 101 | + - name: Install dependencies |
| 102 | + run: | |
| 103 | + python -m pip install --upgrade pip |
| 104 | + pip install setuptools wheel twine |
| 105 | +
|
| 106 | + #- name: Publish python package |
| 107 | + # id: publish_package |
| 108 | + # env: |
| 109 | + # TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 110 | + # TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 111 | + # run: | |
| 112 | + # twine upload dist/* |
| 113 | +
|
| 114 | + - name: Create Release |
| 115 | + id: create_release |
| 116 | + uses: actions/create-release@v1 |
| 117 | + env: |
| 118 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 119 | + with: |
| 120 | + tag_name: ${{ github.ref }} |
| 121 | + release_name: Release ${{ github.ref }} |
| 122 | + draft: false |
| 123 | + prerelease: false |
| 124 | + - name: Upload Release Asset |
| 125 | + id: upload-release-asset |
| 126 | + env: |
| 127 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + run: | |
| 129 | + python -m pip install --upgrade pip |
| 130 | + set -x |
| 131 | + assets=() |
| 132 | + for asset in ./dist/*/*; do |
| 133 | + assets+=("-a" "$asset") |
| 134 | + done |
| 135 | + tag_name="${GITHUB_REF##*/}" |
| 136 | + hub release create "${assets[@]}" -m "$tag_name" "$tag_name" |
0 commit comments