|
1 | | ---- |
2 | | -name: PyPi Build and Deploy 🐍📦 |
| 1 | +# Workflow from https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ |
| 2 | +name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI |
3 | 3 |
|
4 | 4 | on: |
5 | 5 | release: |
6 | 6 | types: [published] |
7 | | - # use this for testing |
8 | 7 | push: |
| 8 | + # Use this for testing the package build. |
9 | 9 | branches: |
10 | 10 | - main |
| 11 | + - v[0-9]+.[0-9]+.x # matches release branches like v2.12.x |
11 | 12 |
|
12 | 13 | jobs: |
13 | | - build-n-publish: |
14 | | - name: Build and publish ESMValTool on PyPi |
| 14 | + build: |
| 15 | + name: Build distribution 📦 |
15 | 16 | runs-on: ubuntu-latest |
16 | | - environment: |
17 | | - name: pypi |
18 | | - url: https://pypi.org/project/ESMValTool/ |
19 | | - permissions: |
20 | | - # IMPORTANT: this permission is mandatory for trusted publishing |
21 | | - id-token: write |
| 17 | + |
22 | 18 | steps: |
23 | 19 | - uses: actions/checkout@v6 |
24 | 20 | with: |
25 | 21 | fetch-depth: 0 |
26 | | - - name: Set up Python 3.13 |
| 22 | + persist-credentials: false |
| 23 | + - name: Set up Python |
27 | 24 | uses: actions/setup-python@v6 |
28 | 25 | with: |
29 | | - python-version: "3.13" |
30 | | - - name: Install pep517 |
| 26 | + python-version: "3.x" |
| 27 | + - name: Install pypa/build |
31 | 28 | run: >- |
32 | | - python -m |
| 29 | + python3 -m |
33 | 30 | pip install |
34 | | - pep517 |
| 31 | + build |
35 | 32 | --user |
36 | 33 | - name: Build a binary wheel and a source tarball |
37 | | - run: >- |
38 | | - python -m |
39 | | - pep517.build |
40 | | - --source |
41 | | - --binary |
42 | | - --out-dir dist/ |
43 | | - . |
44 | | - # - name: Publish distribution to Test PyPI |
45 | | - # uses: pypa/gh-action-pypi-publish@v1.13.0 |
46 | | - # with: |
47 | | - # repository-url: https://test.pypi.org/legacy/ |
| 34 | + run: python3 -m build |
| 35 | + - name: Store the distribution packages |
| 36 | + uses: actions/upload-artifact@v7 |
| 37 | + with: |
| 38 | + name: python-package-distributions |
| 39 | + path: dist/ |
| 40 | + |
| 41 | + publish-to-pypi: |
| 42 | + name: >- |
| 43 | + Publish Python 🐍 distribution 📦 to PyPI |
| 44 | + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes |
| 45 | + needs: |
| 46 | + - build |
| 47 | + runs-on: ubuntu-latest |
| 48 | + environment: |
| 49 | + name: pypi |
| 50 | + url: https://pypi.org/p/ESMValTool |
| 51 | + permissions: |
| 52 | + id-token: write # IMPORTANT: mandatory for trusted publishing |
| 53 | + |
| 54 | + steps: |
| 55 | + - name: Download all the dists |
| 56 | + uses: actions/download-artifact@v8 |
| 57 | + with: |
| 58 | + name: python-package-distributions |
| 59 | + path: dist/ |
48 | 60 | - name: Publish distribution 📦 to PyPI |
49 | | - if: startsWith(github.ref, 'refs/tags') |
50 | 61 | uses: pypa/gh-action-pypi-publish@v1.13.0 |
0 commit comments