|
6 | 6 | branches: |
7 | 7 | - main |
8 | 8 | jobs: |
9 | | - build-publish: |
| 9 | + # setup build separate from publish |
| 10 | + # See https://github.com/pypa/gh-action-pypi-publish/issues/217#issuecomment-1965727093 |
| 11 | + build: |
10 | 12 | runs-on: ubuntu-latest |
11 | 13 | # This ensures that the publish action only runs in the main repository |
12 | 14 | # rather than forks |
13 | 15 | # Environment is encouraged so adding |
14 | | - environment: release |
15 | | - if: github.repository_owner == 'pyopensci' |
16 | | - permissions: |
17 | | - id-token: write # this permission is mandatory for pypi publishing |
| 16 | + environment: build |
18 | 17 | steps: |
19 | 18 | - name: Checkout |
20 | 19 | uses: actions/checkout@v4 |
@@ -42,17 +41,31 @@ jobs: |
42 | 41 | echo "" |
43 | 42 | echo "Generated files:" |
44 | 43 | ls -lh dist/ |
45 | | -
|
46 | | - - name: Publish package on test PyPI on merge in main branch |
47 | | - # Test push to test pypi on merge to main |
48 | | - if: github.event_name == 'push' |
49 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
| 44 | + # Store an artifact of the build to use in the publish step below |
| 45 | + - name: Store the distribution packages |
| 46 | + uses: actions/upload-artifact@v4 |
50 | 47 | with: |
51 | | - repository-url: https://test.pypi.org/legacy/ |
52 | | - # Allow existing releases on test PyPI without errors. |
53 | | - # NOT TO BE USED in PyPI! |
54 | | - skip-existing: true |
55 | | - |
| 48 | + name: python-package-distributions |
| 49 | + path: dist/ |
| 50 | + publish: |
| 51 | + name: >- |
| 52 | + Publish Python 🐍 distribution 📦 to PyPI |
| 53 | + if: github.repository_owner == 'pyopensci' |
| 54 | + needs: |
| 55 | + - build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + environment: |
| 58 | + name: pypi |
| 59 | + url: https://pypi.org/p/pyosmeta |
| 60 | + permissions: |
| 61 | + id-token: write # this permission is mandatory for pypi publishing |
| 62 | + steps: |
| 63 | + # Version 4 doesn't support github enterprise yet |
| 64 | + - name: Download all the dists |
| 65 | + uses: actions/download-artifact@v4 |
| 66 | + with: |
| 67 | + name: python-package-distributions |
| 68 | + path: dist/ |
56 | 69 | - name: Publish package to PyPI |
57 | 70 | # Only publish to real PyPI on release |
58 | 71 | if: github.event_name == 'release' |
|
0 commit comments