■ ■ ■ ■ ■ ■
.github/workflows/pypi.yml
| 1 | + | name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 2 | + | |
| 3 | + | on: push |
| 4 | + | jobs: |
| 5 | + | build-n-publish: |
| 6 | + | name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI |
| 7 | + | runs-on: ubuntu-latest |
| 8 | + | steps: |
| 9 | + | - uses: actions/checkout@master |
| 10 | + | - name: Set up Python 3.10 |
| 11 | + | uses: actions/setup-python@v3 |
| 12 | + | with: |
| 13 | + | python-version: "3.10" |
| 14 | + | - name: Install pypa/build |
| 15 | + | run: >- |
| 16 | + | python -m |
| 17 | + | pip install |
| 18 | + | build |
| 19 | + | --user |
| 20 | + | - name: Build a binary wheel and a source tarball |
| 21 | + | run: >- |
| 22 | + | python -m |
| 23 | + | build |
| 24 | + | --sdist |
| 25 | + | --wheel |
| 26 | + | --outdir dist/ |
| 27 | + | . |
| 28 | + | - name: Publish distribution 📦 to Test PyPI |
| 29 | + | uses: pypa/gh-action-pypi-publish@release/v1 |
| 30 | + | with: |
| 31 | + | password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 32 | + | repository_url: https://test.pypi.org/legacy/ |
| 33 | + | - name: Publish distribution 📦 to PyPI |
| 34 | + | if: startsWith(github.ref, 'refs/tags') |
| 35 | + | uses: pypa/gh-action-pypi-publish@release/v1 |
| 36 | + | with: |
| 37 | + | password: ${{ secrets.PYPI_API_TOKEN }} |