|
| 1 | +name: Python package |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + release: |
| 7 | + types: |
| 8 | + - published |
| 9 | + |
| 10 | +jobs: |
| 11 | + test: |
| 12 | + |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 16 | + python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9] |
| 17 | + exclude: |
| 18 | + - os: windows-latest |
| 19 | + python-version: 2.7 |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v2 |
| 24 | + with: |
| 25 | + submodules: true |
| 26 | + - name: Set up Python ${{ matrix.python-version }} |
| 27 | + uses: actions/setup-python@v2 |
| 28 | + with: |
| 29 | + python-version: ${{ matrix.python-version }} |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install setuptools wheel cython |
| 33 | + - name: Build |
| 34 | + run: | |
| 35 | + python setup.py build_ext --inplace |
| 36 | + - name: Run tests |
| 37 | + run: | |
| 38 | + python test.py |
| 39 | +
|
| 40 | + build-wheels: |
| 41 | + #if: github.event_name == 'release' && github.event.action == 'published' |
| 42 | + needs: test |
| 43 | + |
| 44 | + strategy: |
| 45 | + matrix: |
| 46 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 47 | + runs-on: ${{ matrix.os }} |
| 48 | + |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v2 |
| 51 | + with: |
| 52 | + submodules: true |
| 53 | + - name: Set up Python ${{ matrix.python-version }} |
| 54 | + uses: actions/setup-python@v2 |
| 55 | + with: |
| 56 | + python-version: 3.8 |
| 57 | + - name: Install dependencies |
| 58 | + run: | |
| 59 | + python -m pip install setuptools wheel cython cibuildwheel |
| 60 | + - name: Build wheels |
| 61 | + run: | |
| 62 | + python -m cibuildwheel --output-dir wheelhouse |
| 63 | + env: |
| 64 | + CIBW_SKIP: cp27-win* |
| 65 | + - uses: actions/upload-artifact@v2 |
| 66 | + with: |
| 67 | + path: ./wheelhouse/*.whl |
| 68 | + |
| 69 | + build-sdist: |
| 70 | + #if: github.event_name == 'release' && github.event.action == 'published' |
| 71 | + needs: test |
| 72 | + |
| 73 | + runs-on: ubuntu-latest |
| 74 | + |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v2 |
| 77 | + with: |
| 78 | + submodules: true |
| 79 | + - name: Set up Python 3.8 |
| 80 | + uses: actions/setup-python@v2 |
| 81 | + with: |
| 82 | + python-version: 3.8 |
| 83 | + - name: Install dependencies |
| 84 | + run: | |
| 85 | + python -m pip install setuptools cython |
| 86 | + - name: Build dists |
| 87 | + run: | |
| 88 | + python setup.py sdist |
| 89 | + - uses: actions/upload-artifact@v2 |
| 90 | + with: |
| 91 | + path: dist/*.tar.gz |
| 92 | + |
| 93 | + upload-pypi: |
| 94 | + # upload to PyPI on every tag starting with 'v' |
| 95 | + # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 96 | + # alternatively, to publish when a GitHub Release is created, use the following rule: |
| 97 | + if: github.event_name == 'release' && github.event.action == 'published' |
| 98 | + needs: [build-wheels, build-sdist] |
| 99 | + runs-on: ubuntu-latest |
| 100 | + |
| 101 | + steps: |
| 102 | + - uses: actions/download-artifact@v2 |
| 103 | + with: |
| 104 | + name: artifact |
| 105 | + path: dist |
| 106 | + |
| 107 | + - uses: pypa/gh-action-pypi-publish@master |
| 108 | + with: |
| 109 | + user: __token__ |
| 110 | + password: ${{ secrets.pypi_password }} |
0 commit comments