|
| 1 | +name: Upload Python Package to π¦ PyPi |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +jobs: |
| 8 | + final-tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + python-version: [3.6, 3.7, 3.8, 3.9] |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + - name: Set up Python ${{ matrix.python-version }} |
| 17 | + uses: actions/setup-python@v2 |
| 18 | + with: |
| 19 | + python-version: ${{ matrix.python-version }} |
| 20 | + - name: Install dependencies |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade pip |
| 23 | + python -m pip install flake8 pytest |
| 24 | + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi |
| 25 | + if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi |
| 26 | + - name: Check Apache2 License |
| 27 | + run: | |
| 28 | + apache-license-check --copyright "2021 ABSA Group Limited" |
| 29 | + - name: Lint with flake8 |
| 30 | + run: | |
| 31 | + # stop the build if there are Python syntax errors or undefined names |
| 32 | + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
| 33 | + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide |
| 34 | + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
| 35 | + - name: Test with pytest |
| 36 | + run: | |
| 37 | + pytest |
| 38 | +
|
| 39 | + deploy: |
| 40 | + needs: final-tests |
| 41 | + runs-on: ubuntu-20.04 |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@master |
| 45 | + - name: Set up Python 3.8 |
| 46 | + uses: actions/setup-python@v1 |
| 47 | + with: |
| 48 | + python-version: 3.8 |
| 49 | + |
| 50 | + - name: Install pypa/build |
| 51 | + run: >- |
| 52 | + python -m |
| 53 | + pip install |
| 54 | + build |
| 55 | + --user |
| 56 | + - name: Build a binary wheel and a source tarball |
| 57 | + run: >- |
| 58 | + python -m |
| 59 | + build |
| 60 | + --sdist |
| 61 | + --wheel |
| 62 | + --outdir dist/ |
| 63 | + . |
| 64 | +
|
| 65 | + - name: Publish distribution π¦ to PyPI |
| 66 | + uses: pypa/gh-action-pypi-publish@master |
| 67 | + with: |
| 68 | + password: ${{ secrets.PYPI_API_TOKEN }} |
0 commit comments