Skip to content

Commit d135615

Browse files
committed
Use trusted-publishing instead of long-lived token
Run job under an environment called 'pypi', set permissions: id-token: write, and don't use PYPI_TOKEN upload. Xref https://github.com/pypa/gh-action-pypi-publish/tree/v1.14.0?tab=readme-ov-file#trusted-publishing.
1 parent c97a929 commit d135615

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

.github/workflows/pypi-release.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,17 @@ jobs:
6262
name: releases
6363
path: dist
6464

65-
upload-to-pypi:
65+
pypi-publish:
66+
name: Publish Python 🐍 distribution 📦 to PyPI
6667
needs: build-artifacts
67-
if: github.event_name == 'release'
68+
if: github.repository == 'xarray-contrib/cupy-xarray' && startsWith(github.ref, 'refs/tags')
6869
runs-on: ubuntu-latest
70+
environment:
71+
name: pypi
72+
url: https://pypi.org/project/cupy-xarray/
73+
permissions:
74+
id-token: write # IMPORTANT: mandatory for trusted OIDC publishing
75+
6976
steps:
7077
- uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5.0.0
7178
with:
@@ -75,6 +82,5 @@ jobs:
7582
- name: Publish package to PyPI
7683
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # v1.14.0
7784
with:
78-
user: __token__
79-
password: ${{ secrets.PYPI_TOKEN }}
85+
print-hash: true
8086
verbose: true

0 commit comments

Comments
 (0)