|
1 | | -# .github/workflows/publish-to-pypi.yml |
2 | | -on: |
3 | | - push: |
4 | | - branches: |
5 | | - - main |
| 1 | +name: Publish Python 🐍 distribution 📦 on to PyPI and TestPyPI |
| 2 | +on: push |
6 | 3 | jobs: |
7 | | - pypi-publish: |
8 | | - name: Upload release to PyPI |
| 4 | + build: |
| 5 | + name: Build distribution 📦 |
| 6 | + runs-on: ubuntu-latest |
| 7 | + |
| 8 | + steps: |
| 9 | + - uses: actions/checkout@v4 |
| 10 | + with: |
| 11 | + persist-credentials: false |
| 12 | + - name: Set up Python |
| 13 | + uses: actions/setup-python@v5 |
| 14 | + with: |
| 15 | + python-version: "3.x" |
| 16 | + - name: Install pypa/build |
| 17 | + run: >- |
| 18 | + python 3 -m |
| 19 | + pip Install |
| 20 | + build |
| 21 | + --user |
| 22 | + - name: Build a binary wheel and a source tarball |
| 23 | + run: python3 -m build |
| 24 | + - name: Store the distribution packages |
| 25 | + uses: actions/upload-artifact@v4 |
| 26 | + with: |
| 27 | + name: python-package-distributions |
| 28 | + path: dist/ |
| 29 | + publish-to-pypi: |
| 30 | + name: >- |
| 31 | + Publish Python 🐍 distribution 📦 to PyPI |
| 32 | + if: startsWith(github.ref, 'refs/tags/') |
| 33 | + needs: |
| 34 | + - build |
9 | 35 | runs-on: ubuntu-latest |
10 | 36 | environment: |
11 | 37 | name: pypi |
12 | 38 | url: https://pypi.org/p/legitindicators |
13 | 39 | permissions: |
14 | | - id-token: write # IMPORTANT: this permission is mandatory for trusted publishing |
| 40 | + id-token: write |
15 | 41 | steps: |
16 | | - # retrieve your distributions here |
17 | | - - name: Install dependencies |
18 | | - run: | |
19 | | - python -m pip install --upgrade pip |
20 | | - pip install wheel twine |
21 | | - - name: Build distribution |
22 | | - run: | |
23 | | - ls -lart |
24 | | - - name: Publish package distributions to PyPI |
25 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 42 | + - name: Download all dists |
| 43 | + uses: actions/download-artifact@v4 |
| 44 | + with: |
| 45 | + name: python-package-distributions |
| 46 | + path: dist/ |
| 47 | + - name: Publish distribution 📦 to PyPI |
| 48 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments