Skip to content

Commit 2de3a43

Browse files
authored
Merge pull request #661 from lmmx/trusted-publishing
Upgrade PyPI CI publishing to use Trusted Publishing
2 parents 0b1a30c + 2fab141 commit 2de3a43

1 file changed

Lines changed: 26 additions & 7 deletions

File tree

.github/workflows/publish.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,15 @@ permissions:
2929

3030
jobs:
3131
build_and_publish:
32-
# This job builds the wheels and publishes them to PyPI for all
33-
# tags, except those ending in ".dev". For PRs with the "Build all
34-
# wheels" label, wheels are built, but are not uploaded to PyPI.
35-
3632
permissions:
3733
contents: none
3834

3935
uses: OpenAstronomy/github-actions-workflows/.github/workflows/publish.yml@2835f0cacddf3f8de198db9afdb5354a5cebe0ef # v2.6.3
4036

4137
if: (github.repository == 'astropy/regions' && (github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'Build all wheels')))
4238
with:
43-
# We upload to PyPI for all tag pushes, except tags ending in .dev
44-
upload_to_pypi: ${{ startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '.dev') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
39+
upload_to_pypi: false
40+
save_artifacts: true
4541

4642
test_extras: test
4743
test_command: pytest -p no:warnings --pyargs regions
@@ -63,5 +59,28 @@ jobs:
6359
anaconda_keep_n_latest: 10
6460

6561
secrets:
66-
pypi_token: ${{ secrets.pypi_token }}
6762
anaconda_token: ${{ secrets.anaconda_token }}
63+
64+
upload:
65+
# This job publishes the built wheels to PyPI for all tags, except
66+
# those ending in ".dev". For PRs with the "Build all wheels" label,
67+
# wheels are built, but are not uploaded to PyPI.
68+
permissions:
69+
id-token: write
70+
environment:
71+
name: pypi
72+
url: https://pypi.org/project/regions
73+
# We upload to PyPI for all tag pushes, except tags ending in .dev
74+
if: startsWith(github.ref, 'refs/tags/') && !endsWith(github.ref, '.dev') && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
75+
name: Upload release to PyPI
76+
runs-on: ubuntu-latest
77+
needs: [build_and_publish]
78+
steps:
79+
- name: Download artifacts
80+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
81+
with:
82+
merge-multiple: true
83+
pattern: dist-*
84+
path: dist
85+
- name: Upload to PyPI
86+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0

0 commit comments

Comments
 (0)