Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to PyPI from a github workflow by declaring the workflow to be trusted #648

Open
consideRatio opened this issue Apr 24, 2023 · 1 comment

Comments

@consideRatio
Copy link
Member

In this PyPI blog post we learn about a new feature that makes us no longer need to setup PyPI projects with maintainer rights to jupyterhub-bot account and then generate a scoped deployment token. Instead, we can just declare a github project's workflow to be trusted, add permissions.id-token: write, and finally use the pypa/gh-action-pypi-publish action.

To me, this sounds great! I intend to pilot use of this in jupyterhub/tmpauthenticator

jobs:
   pypi-publish:
     name: upload release to PyPI
     runs-on: ubuntu-latest
+    permissions:
+      # IMPORTANT: this permission is mandatory for trusted publishing
+      id-token: write
     steps:
       # retrieve your distributions here

       - name: Publish package distributions to PyPI
         uses: pypa/gh-action-pypi-publish@release/v1
-        with:
-          username: __token__
-          password: ${{ secrets.PYPI_TOKEN }}

Related

@manics
Copy link
Member

manics commented Apr 24, 2023

Sounds good to me. It's using OIDC, which is the same process that GitHub workflows use to authenticate with public cloud providers with a temporary token instead of using fixed secret credentials. When we're migrating existing workflows we should also delete the original tokens from PyPI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants