Replace exposed PyPI token with trusted publishing - #60
Conversation
There was a problem hiding this comment.
Pull request overview
This PR remediates release workflow security by removing reliance on a long-lived PyPI API token and switching the deploy job to PyPI Trusted Publishing via GitHub OIDC, scoped to a dedicated pypi environment.
Changes:
- Configure the
deployjob to run in thepypiGitHub environment and attach the PyPI project URL. - Scope job permissions to enable OIDC (
id-token: write) for publishing. - Switch PyPI publish action from a token-based
@masterreference topypa/gh-action-pypi-publish@release/v1(Trusted Publishing).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| uses: pypa/gh-action-pypi-publish@master | ||
| with: | ||
| password: ${{ secrets.PYPI_API_TOKEN }} | ||
| uses: pypa/gh-action-pypi-publish@release/v1 |
| @@ -107,9 +113,7 @@ jobs: | |||
| run: | | |||
| python setup.py sdist bdist_wheel | |||
| - name: Publish distribution to PyPi | |||
|
The 0.3 stacked release implementation in #89 supersedes this workflow-only change. Repository Actions secrets PAT, PYPI_API_TOKEN, and TEST_PYPI_API_TOKEN have been removed; only SONAR_HOST_URL and SONAR_TOKEN remain. Please do not merge both implementations. Keep this PR open until the new stack is reviewed, then close it as superseded. PyPI/TestPyPI token revocation and audit-log confirmation are tracked in #99. |
Security remediation
PYPI_API_TOKEN@masteraction reference to@release/v1pypiGitHub environmentBefore the next release, configure the
urbanpyproject on PyPI with a GitHub Trusted Publisher for ownerEL-BID, repositoryurbanpy, workflowmain.yml, environmentpypi.