-
Notifications
You must be signed in to change notification settings - Fork 3
Fix PyPI publishing workflow to use API token instead of trusted publishing #24
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
Conversation
…ishing Co-authored-by: deepentropy <8287111+deepentropy@users.noreply.github.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a PyPI publishing workflow failure caused by OIDC trusted publisher claim mismatches. The workflow now uses explicit API token authentication instead of relying on GitHub's OIDC trusted publishing flow.
Key Changes:
- Switched from OIDC trusted publishing to API token authentication
- Removed the
environment: pypiblock that was causing claim mismatches - Updated the publish job conditional to explicitly check for 'published' release action
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| # Only run this job for published releases | ||
| if: github.event_name == 'release' && github.event.action == 'published' |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conditional if: github.event_name == 'release' && github.event.action == 'published' will prevent this job from running when triggered via workflow_dispatch. If manual publishing is needed, the workflow won't work.
Consider using:
if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch'This ensures the publish job runs both on release publications and manual triggers.
| # Only run this job for published releases | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| # Only run this job for published releases or manual triggers | |
| if: (github.event_name == 'release' && github.event.action == 'published') || github.event_name == 'workflow_dispatch' |
| id-token: write | ||
| contents: read |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Since the workflow now uses API token authentication (password: ${{ secrets.PYPI_API_TOKEN }}), the id-token: write permission is no longer necessary. The OIDC token won't be used when an explicit password is provided.
Consider removing id-token: write from both top-level and job-level permissions unless you plan to use trusted publishing in the future. This follows the principle of least privilege.
| if: github.event_name == 'release' && github.event.action == 'published' | ||
| permissions: | ||
| id-token: write # IMPORTANT: mandatory for trusted publishing | ||
| id-token: write |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Since the workflow now uses API token authentication (password: ${{ secrets.PYPI_API_TOKEN }}), the id-token: write permission is no longer necessary at the job level. The OIDC token won't be used when an explicit password is provided.
Consider removing this permission unless you plan to use trusted publishing in the future. This follows the principle of least privilege.
| id-token: write |
PyPI rejected the OIDC trusted publisher flow with
invalid-publishererror because the workflow'senvironment: pypiblock added claims that didn't match PyPI's trusted publisher configuration.Changes
environment: pypiblock to eliminate claim mismatchpassword: ${{ secrets.PYPI_API_TOKEN }}to use explicit API token authid-token: writeto top-level permissionscontents: readto job-level permissionsgithub.event_name == 'release' && github.event.action == 'published'Required Setup
After merge, create repository secret
PYPI_API_TOKENwith a PyPI API token scoped to the numta package.Alternatively, reconfigure PyPI trusted publisher to match this repository/workflow without environment claims.
Original prompt
This pull request was created as a result of the following prompt from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.