|
1 | | -name: Build and deploy |
| 1 | +name: Publish to PyPI |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_dispatch: |
5 | | -# push: |
6 | | -# # Sequence of patterns matched against refs/tags |
7 | | -# tags: |
8 | | -# - '[0-9]+.[0-9]+.[0-9]+' # Push events to any matching semantic tag. For example, 1.10.1 or 2.0.0. |
9 | 5 | release: |
10 | | - types: |
11 | | - - published |
| 6 | + types: [published] |
12 | 7 |
|
13 | 8 | jobs: |
14 | | - dist: |
| 9 | + build: |
| 10 | + name: Build distribution |
15 | 11 | runs-on: ubuntu-latest |
| 12 | + |
16 | 13 | steps: |
17 | | - - uses: actions/checkout@v1 |
| 14 | + - uses: actions/checkout@v4 |
18 | 15 |
|
19 | | - - name: Build wheel and SDist |
20 | | - run: pipx run build |
| 16 | + - name: Set up Python |
| 17 | + uses: actions/setup-python@v5 |
| 18 | + with: |
| 19 | + python-version: "3.12" |
21 | 20 |
|
22 | | - - uses: actions/upload-artifact@v4 |
23 | | - with: |
24 | | - path: dist/* |
| 21 | + - name: Install build |
| 22 | + run: pip install build |
25 | 23 |
|
26 | | - - name: Check metadata |
27 | | - run: pipx run twine check dist/* |
| 24 | + - name: Build sdist and wheel |
| 25 | + run: python -m build |
28 | 26 |
|
| 27 | + - name: Upload dist artifacts |
| 28 | + uses: actions/upload-artifact@v4 |
| 29 | + with: |
| 30 | + name: dist |
| 31 | + path: dist/ |
29 | 32 |
|
30 | 33 | publish: |
31 | | - needs: [dist] |
| 34 | + name: Publish to PyPI |
| 35 | + needs: build |
32 | 36 | runs-on: ubuntu-latest |
33 | | - # upload to PyPI on every tag starting with 'v' |
34 | | - # if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') |
35 | | - # alternatively, to publish when a GitHub Release is created, use the following rule: |
36 | | - if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' |
| 37 | + environment: release |
| 38 | + permissions: |
| 39 | + id-token: write # required for OIDC trusted publishing |
37 | 40 |
|
38 | 41 | steps: |
39 | | - - uses: actions/download-artifact@v4 |
40 | | - with: |
41 | | - name: artifact |
42 | | - path: dist |
43 | | - |
44 | | - - name: Publish distribution 📦 to PyPI |
45 | | - uses: pypa/gh-action-pypi-publish@v1.9.0 |
46 | | - with: |
47 | | - password: ${{ secrets.PYPI_API_TOKEN_PYCBA }} |
48 | | - # remove following once testing complete |
49 | | - # user: __token__ |
50 | | - # password: ${{ secrets.TEST_PYPI_API_TOKEN_PYCBA }} |
51 | | - # repository_url: https://test.pypi.org/legacy/ |
52 | | - |
| 42 | + - name: Download dist artifacts |
| 43 | + uses: actions/download-artifact@v4 |
| 44 | + with: |
| 45 | + name: dist |
| 46 | + path: dist/ |
| 47 | + |
| 48 | + - name: Publish to PyPI |
| 49 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments