| 1 | name: Production Python package |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | branches: |
| 6 | - master |
| 7 | |
| 8 | jobs: |
| 9 | build: |
| 10 | |
| 11 | runs-on: ubuntu-latest |
| 12 | |
| 13 | steps: |
| 14 | - uses: actions/checkout@v2 |
| 15 | - name: Set up Python 3.x |
| 16 | uses: actions/setup-python@v2 |
| 17 | with: |
| 18 | python-version: '3.9' |
| 19 | architecutre: 'x64' |
| 20 | - name: Install dependencies |
| 21 | run: | |
| 22 | python -m pip install --upgrade pip |
| 23 | pip install flake8 pytest |
| 24 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 25 | - name: Lint with flake8 |
| 26 | run: | |
| 27 | # stop the build if there are Python syntax errors or undefined names |
| 28 | flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 29 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 30 | flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 31 | - name: Test with pytest |
| 32 | run: | |
| 33 | pytest |
| 34 | - name: build package |
| 35 | run: | |
| 36 | pip install wheel twine |
| 37 | python setup.py sdist bdist_wheel && twine check dist/* |
| 38 | - name: Publish a Python distribution to PyPI |
| 39 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 40 | with: |
| 41 | user: __token__ |
| 42 | password: ${{ secrets.PYPI_API_TOKEN }} |
| 43 | |
| 44 |