| 1 | name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 2 | |
| 3 | on: push |
| 4 | |
| 5 | jobs: |
| 6 | build-n-publish: |
| 7 | name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 8 | runs-on: ubuntu-18.04 |
| 9 | steps: |
| 10 | - uses: actions/checkout@master |
| 11 | with: |
| 12 | fetch-depth: 20 |
| 13 | - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* |
| 14 | - name: Set up Python 3.8 |
| 15 | uses: actions/setup-python@v1 |
| 16 | with: |
| 17 | python-version: 3.8 |
| 18 | - name: Install pep517 and twine |
| 19 | run: python -m pip install pep517 twine --user |
| 20 | - name: Build a binary wheel and a source tarball |
| 21 | run: python -m pep517.build --source --binary --out-dir dist/ ./ |
| 22 | - name: twine check |
| 23 | run: python -m twine check dist/* |
| 24 | - name: Publish distribution 📦 to Test PyPI |
| 25 | if: startsWith(github.event.ref, 'refs/heads/master') |
| 26 | uses: pypa/gh-action-pypi-publish@master |
| 27 | with: |
| 28 | password: ${{ secrets.testpypi_password }} |
| 29 | repository_url: https://test.pypi.org/legacy/ |
| 30 | - name: Publish distribution 📦 to PyPI |
| 31 | if: startsWith(github.event.ref, 'refs/tags') |
| 32 | uses: pypa/gh-action-pypi-publish@master |
| 33 | with: |
| 34 | password: ${{ secrets.pypi_password }} |