|
1 | | -name: Publish Python distributions to PyPI and TestPyPI |
| 1 | +name: Publish Python 🐍 distribution 📦 to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | release: |
5 | | - types: [published] |
6 | | - |
| 5 | + types: [created] |
7 | 6 |
|
8 | 7 | jobs: |
9 | | - build-n-publish: |
10 | | - name: Build and publish Python distributions to PyPI and TestPyPI |
11 | | - runs-on: ubuntu-20.04 |
| 8 | + build: |
| 9 | + name: Build distribution 📦 |
| 10 | + runs-on: ubuntu-latest |
12 | 11 | steps: |
13 | | - - uses: actions/checkout@master |
14 | | - - name: Set up Python 3.10 |
15 | | - uses: actions/setup-python@v1 |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + - name: Set up Python |
| 14 | + uses: actions/setup-python@v4 |
16 | 15 | with: |
17 | | - python-version: "3.10" |
| 16 | + python-version: "3.x" |
18 | 17 | - name: Install pypa/build |
19 | | - run: python -m pip install build hatch --user |
| 18 | + run: >- |
| 19 | + python3 -m |
| 20 | + pip install |
| 21 | + build |
| 22 | + --user |
20 | 23 | - name: Build a binary wheel and a source tarball |
21 | | - run: python -m build --sdist --wheel --outdir dist/ |
22 | | - |
23 | | - # Publish the package to test.pypi for every rc version |
24 | | - - name: Publish distribution to Test PyPI |
25 | | - if: "startsWith(github.ref, 'refs/tags') && contains(github.ref, 'rc')" |
26 | | - uses: pypa/gh-action-pypi-publish@master |
| 24 | + run: python3 -m build |
| 25 | + - name: Store the distribution packages |
| 26 | + uses: actions/upload-artifact@v3 |
27 | 27 | with: |
28 | | - password: ${{ secrets.test_pypi_password }} |
29 | | - repository_url: http://test.pypi.org/legacy/ |
| 28 | + name: python-package-distributions |
| 29 | + path: dist/ |
30 | 30 |
|
31 | | - # Publish a tagged version on PyPI for non-release candidates |
32 | | - - name: Publish distribution to PyPI |
33 | | - if: "startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'rc')" |
34 | | - uses: pypa/gh-action-pypi-publish@master |
| 31 | + publish-to-pypi: |
| 32 | + name: >- |
| 33 | + Publish Python 🐍 distribution 📦 to PyPI |
| 34 | + needs: |
| 35 | + - build |
| 36 | + runs-on: ubuntu-latest |
| 37 | + environment: |
| 38 | + name: pypi |
| 39 | + url: https://pypi.org/p/era5cli |
| 40 | + permissions: |
| 41 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 42 | + steps: |
| 43 | + - name: Download all the dists |
| 44 | + uses: actions/download-artifact@v3 |
35 | 45 | with: |
36 | | - password: ${{ secrets.pypi_password }} |
| 46 | + name: python-package-distributions |
| 47 | + path: dist/ |
| 48 | + - name: Publish distribution 📦 to PyPI |
| 49 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments