|
1 |
| -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions |
2 |
| -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions |
3 |
| - |
4 |
| -name: Python package |
| 1 | +name: Build and upload to PyPI |
5 | 2 |
|
6 | 3 | on: [push, pull_request]
|
7 | 4 |
|
8 | 5 | jobs:
|
9 |
| - build: |
10 |
| - |
11 |
| - runs-on: ubuntu-latest |
| 6 | + build_wheels: |
| 7 | + name: Build wheels on ${{ matrix.os }} |
| 8 | + runs-on: ${{ matrix.os }} |
12 | 9 | strategy:
|
13 | 10 | matrix:
|
14 |
| - python-version: [3.6, 3.7, 3.8] |
| 11 | + os: [ubuntu-18.04, windows-latest, macos-latest] |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v2 |
| 15 | + |
| 16 | + - uses: actions/setup-python@v2 |
| 17 | + name: Install Python |
| 18 | + with: |
| 19 | + python-version: '3.7' |
15 | 20 |
|
| 21 | + - name: Install cibuildwheel |
| 22 | + run: | |
| 23 | + python -m pip install cibuildwheel==1.5.1 |
| 24 | + - name: Install Visual C++ for Python 2.7 |
| 25 | + if: runner.os == 'Windows' |
| 26 | + run: | |
| 27 | + choco install vcpython27 -f -y |
| 28 | + - name: Build wheels |
| 29 | + run: | |
| 30 | + python -m cibuildwheel --output-dir wheelhouse |
| 31 | + - uses: actions/upload-artifact@v2 |
| 32 | + with: |
| 33 | + path: ./wheelhouse/*.whl |
| 34 | + |
| 35 | + build_sdist: |
| 36 | + name: Build source distribution |
| 37 | + runs-on: ubuntu-latest |
16 | 38 | steps:
|
17 |
| - - uses: actions/checkout@v2 |
18 |
| - - name: Set up Python ${{ matrix.python-version }} |
19 |
| - uses: actions/setup-python@v2 |
20 |
| - with: |
21 |
| - python-version: ${{ matrix.python-version }} |
22 |
| - - name: Install dependencies |
23 |
| - run: | |
24 |
| - python -m pip install --upgrade pip |
25 |
| - pip install flake8 pytest |
26 |
| - if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
27 |
| - - name: Lint with flake8 |
28 |
| - run: | |
29 |
| - # stop the build if there are Python syntax errors or undefined names |
30 |
| - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
31 |
| - # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
32 |
| - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
33 |
| - - name: Test with pytest |
34 |
| - run: | |
35 |
| - pytest |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + |
| 41 | + - uses: actions/setup-python@v2 |
| 42 | + name: Install Python |
| 43 | + with: |
| 44 | + python-version: '3.7' |
| 45 | + |
| 46 | + - name: Build sdist |
| 47 | + run: python setup.py sdist |
| 48 | + |
| 49 | + - uses: actions/upload-artifact@v2 |
| 50 | + with: |
| 51 | + path: dist/*.tar.gz |
| 52 | + |
| 53 | + upload_pypi: |
| 54 | + needs: [build_wheels, build_sdist] |
| 55 | + runs-on: ubuntu-latest |
| 56 | + # upload to PyPI on every tag starting with 'v' |
| 57 | + # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
| 58 | + steps: |
| 59 | + - uses: actions/download-artifact@v2 |
| 60 | + with: |
| 61 | + name: artifact |
| 62 | + path: dist |
| 63 | + |
| 64 | + - uses: pypa/gh-action-pypi-publish@master |
| 65 | + with: |
| 66 | + user: __token__ |
| 67 | + password: ${{ secrets.pypi_password }} |
| 68 | + # To test: |
| 69 | + repository_url: https://test.pypi.org/legacy/ |
0 commit comments