ci(pypi): add trusted publisher workflow for PyPI releases#352
ci(pypi): add trusted publisher workflow for PyPI releases#352
Conversation
Summary of ChangesHello @vitali87, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new continuous integration workflow designed to automate the release process for PyPI. By integrating GitHub Actions with OIDC trusted publishers, it establishes a secure and efficient mechanism for deploying new versions of the package, thereby reducing manual overhead and enhancing security by removing the reliance on static API tokens. Highlights
Changelog
Ignored Files
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request updates the version of the code-graph-rag package in the uv.lock file to 0.0.76. This change aligns with the project's version bump and is a necessary step for the new PyPI publishing workflow. The update is correct and I see no issues.
Greptile SummaryAdds a GitHub Actions workflow (
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as Developer
participant GH as GitHub
participant WF as publish.yml
participant UV as uv build
participant PyPI as PyPI (OIDC)
User->>GH: Create Release (e.g. v0.0.76)
GH->>WF: Trigger on release published
WF->>GH: Checkout code (actions/checkout@v4)
WF->>WF: Install uv (astral-sh/setup-uv@v4)
WF->>WF: Set up Python 3.12
WF->>UV: uv build
UV-->>WF: dist/ artifacts (sdist + wheel)
WF->>PyPI: Request OIDC token (id-token: write)
PyPI-->>WF: Verify trusted publisher
WF->>PyPI: Upload package (pypa/gh-action-pypi-publish)
PyPI-->>GH: Published successfully
Last reviewed commit: 1a74fd1 |
| permissions: | ||
| id-token: write |
There was a problem hiding this comment.
Missing contents: read permission
When permissions is set at the job level, it completely overrides the top-level permissions: read-all — unspecified permissions become none (except metadata). This means the actions/checkout step on line 20 has no contents: read permission.
For a public repository, actions/checkout may still succeed via an unauthenticated HTTPS clone fallback, but this is fragile and not the intended behavior. If the repo ever becomes private, or if GitHub changes fallback behavior, the workflow will break. The build-binaries.yml workflow in this repo correctly sets contents: write at the job level for the same reason.
| permissions: | |
| id-token: write | |
| permissions: | |
| id-token: write | |
| contents: read |
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/publish.yml
Line: 15-16
Comment:
**Missing `contents: read` permission**
When `permissions` is set at the job level, it **completely overrides** the top-level `permissions: read-all` — unspecified permissions become `none` (except `metadata`). This means the `actions/checkout` step on line 20 has no `contents: read` permission.
For a public repository, `actions/checkout` may still succeed via an unauthenticated HTTPS clone fallback, but this is fragile and not the intended behavior. If the repo ever becomes private, or if GitHub changes fallback behavior, the workflow will break. The `build-binaries.yml` workflow in this repo correctly sets `contents: write` at the job level for the same reason.
```suggestion
permissions:
id-token: write
contents: read
```
How can I resolve this? If you propose a fix, please make it concise.| run: uv build | ||
|
|
||
| - name: Publish to PyPI | ||
| uses: pypa/gh-action-pypi-publish@release/v1 |
There was a problem hiding this comment.
Action pinned to branch, not SHA
The pypa/gh-action-pypi-publish action is referenced via @release/v1, which is a mutable branch ref. This repo's scorecard.yml pins actions to commit SHAs for supply-chain security (e.g., actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683). While @release/v1 is the pattern recommended by PyPA's own documentation, pinning to a specific SHA would be more consistent with the security posture demonstrated by the Scorecard workflow and would prevent a compromised upstream from injecting malicious code into the publish step — which is particularly sensitive since it pushes packages to PyPI.
Consider pinning to a specific commit SHA:
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| uses: pypa/gh-action-pypi-publish@76f52bc884231f62b54571ab1b17f0ab24dba305 # release/v1 |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: .github/workflows/publish.yml
Line: 37
Comment:
**Action pinned to branch, not SHA**
The `pypa/gh-action-pypi-publish` action is referenced via `@release/v1`, which is a mutable branch ref. This repo's `scorecard.yml` pins actions to commit SHAs for supply-chain security (e.g., `actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683`). While `@release/v1` is the pattern recommended by PyPA's own documentation, pinning to a specific SHA would be more consistent with the security posture demonstrated by the Scorecard workflow and would prevent a compromised upstream from injecting malicious code into the publish step — which is particularly sensitive since it pushes packages to PyPI.
Consider pinning to a specific commit SHA:
```suggestion
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b54571ab1b17f0ab24dba305 # release/v1
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.
Summary
pypiGitHub environment (already created) and the pending publisher registered on PyPI (already configured)Usage
v0.0.76)uv buildand publishes viapypa/gh-action-pypi-publish