|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: Build, Test and Publish |
| 4 | + |
| 5 | +# Controls when the action will run. |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the main branch |
| 8 | + push: |
| 9 | + tags: |
| 10 | + - "v*" |
| 11 | + |
| 12 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 13 | +jobs: |
| 14 | + build-n-publish: |
| 15 | + # The type of runner that the job will run on |
| 16 | + runs-on: windows-2019 |
| 17 | + |
| 18 | + env: |
| 19 | + CIBW_BUILD: cp37-win_amd64 cp38-win_amd64 cp39-win_amd64 |
| 20 | + CIBW_ARCHS: AMD64 |
| 21 | + CIBW_PLATFORM: windows |
| 22 | + CIBW_PROJECT_REQUIRES_PYTHON: ">=3.7" |
| 23 | + CIBW_TEST_REQUIRES: pytest |
| 24 | + CIBW_TEST_COMMAND: "pytest {project}/tests" |
| 25 | + |
| 26 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 27 | + steps: |
| 28 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 29 | + - uses: actions/checkout@v2 |
| 30 | + |
| 31 | + - name: Setup Python |
| 32 | + uses: actions/setup-python@v2.2.1 |
| 33 | + with: |
| 34 | + # Version range or exact version of a Python version to use, using SemVer's version range syntax. |
| 35 | + python-version: "3.x" |
| 36 | + # The target architecture (x86, x64) of the Python interpreter. |
| 37 | + architecture: "x64" |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: | |
| 41 | + python -m pip install --upgrade pip |
| 42 | + pip install cibuildwheel |
| 43 | + pip install cython twine |
| 44 | + |
| 45 | + - name: Build Wheels |
| 46 | + run: python -m cibuildwheel --output-dir wheelhouse |
| 47 | + |
| 48 | + - name: Upload Wheels |
| 49 | + uses: actions/upload-artifact@v2 |
| 50 | + with: |
| 51 | + path: ./wheelhouse/*.whl |
| 52 | + |
| 53 | + - name: Build Source Distribution |
| 54 | + run: python setup.py sdist |
| 55 | + |
| 56 | + - name: Upload Source Distribution |
| 57 | + uses: actions/upload-artifact@v2 |
| 58 | + with: |
| 59 | + path: ./dist/*.zip |
| 60 | + |
| 61 | + upload_pypi: |
| 62 | + need: [build-n-publish] |
| 63 | + runs-on: windows-2019 |
| 64 | + if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 65 | + steps: |
| 66 | + - uses: actions/download-artifact@v2 |
| 67 | + with: |
| 68 | + name: artifact |
| 69 | + path: dist |
| 70 | + |
| 71 | + - uses: pypa/gh-action-pypi-publish@master |
| 72 | + with: |
| 73 | + user: __token__ |
| 74 | + password: ${{ secrets.pypi_password }} |
| 75 | + |
| 76 | + |
0 commit comments