Skip to content

ci: align PyPI publish workflow with trusted publishing#7

Merged
AdishAssain merged 1 commit into
mainfrom
fix/pypi-trusted-publishing
Jun 15, 2026
Merged

ci: align PyPI publish workflow with trusted publishing#7
AdishAssain merged 1 commit into
mainfrom
fix/pypi-trusted-publishing

Conversation

@AdishAssain

@AdishAssain AdishAssain commented Jun 15, 2026

Copy link
Copy Markdown
Member

Why

The PyPI trusted publisher for patchsim was just configured (owner dsih-artpark, repo patchsim, workflow pypi-release.yml, environment pypi). Two things in the repo prevented a release from actually publishing:

  1. Filename mismatch — the workflow file was publish.yml, but the trusted publisher matches on the exact filename pypi-release.yml. OIDC auth would have failed.
  2. Token-based publish — the publish step passed password: ${{ secrets.PYPI_API_TOKEN }}, but no such secret exists (no repo or pypi-env secrets). With trusted publishing we must omit the password so the action uses OIDC.

Changes

  • Rename .github/workflows/publish.yml.github/workflows/pypi-release.yml.
  • Remove the password: from the publish step → action uses Trusted Publishing (OIDC) via the existing id-token: write permission.
  • Drop the unused packages: write permission (not needed for PyPI).

After merge

Cut the first release by publishing a GitHub Release with tag v0.1.0b1 (version is already set in pyproject.toml). The release: published event fires the workflow, which builds, tests, and publishes to PyPI via OIDC.

Note: 0.1.0b1 is a pre-release, so installs need pip install --pre patchsim (or patchsim==0.1.0b1).

Summary by CodeRabbit

  • Chores
    • Updated PyPI release workflow configuration to use modern authentication methods and latest action version.

- Rename publish.yml -> pypi-release.yml to match the PyPI trusted
  publisher config (OIDC matches on the exact workflow filename).
- Drop the API-token password from the publish step so the action
  uses Trusted Publishing (OIDC) via the existing id-token permission.
- Remove the unused packages: write permission (not needed for PyPI).
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PyPI release workflow migrates from API token authentication to OIDC trusted publishing. The publish job permissions are updated to use id-token: write and contents: read instead of packages: write, and the pypa/gh-action-pypi-publish action is updated to @release/v1 with the PYPI_API_TOKEN password input removed.

Changes

PyPI Trusted Publishing Migration

Layer / File(s) Summary
OIDC permissions and publish step
.github/workflows/pypi-release.yml
Job permissions changed from packages: write to id-token: write + contents: read; publish action updated to pypa/gh-action-pypi-publish@release/v1 with PYPI_API_TOKEN password input removed.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

A token once guarded the gate with a key,
Now identity flows cryptographically free!
🐇 The rabbit hops past with a OIDC nod,
No secrets to juggle, no token to prod.
Trusted and signed — what a wonderful day!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: updating the PyPI publish workflow to use trusted publishing with OIDC authentication instead of the legacy password-based approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pypi-trusted-publishing

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/pypi-release.yml:
- Around line 52-53: The Publish step uses a branch reference (`@release/v1`) for
the pypa/gh-action-pypi-publish action, which poses a supply chain security risk
since the workflow has id-token: write permissions. Replace the branch reference
with a pinned commit SHA hash to ensure the exact version of the action is
always used and prevent upstream compromise.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 19fb72ad-c61b-4cfd-8f54-71064893f409

📥 Commits

Reviewing files that changed from the base of the PR and between 5f608cf and c53d6ce.

📒 Files selected for processing (1)
  • .github/workflows/pypi-release.yml

Comment on lines 52 to +53
- name: Publish
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get the current commit SHA for the release/v1 branch of pypa/gh-action-pypi-publish
gh api repos/pypa/gh-action-pypi-publish/git/ref/heads/release/v1 --jq '.object.sha'

Repository: dsih-artpark/patchsim

Length of output: 106


Pin action to a SHA hash for supply chain security.

The pypa/gh-action-pypi-publish action uses a branch reference (@release/v1) instead of a pinned SHA hash. For workflows with id-token: write permissions that publish packages, pinning to a commit SHA provides protection against upstream compromise.

🔒 Suggested fix
       - name: Publish
-        uses: pypa/gh-action-pypi-publish@release/v1
+        uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b  # release/v1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Publish
uses: pypa/gh-action-pypi-publish@v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@release/v1
- name: Publish
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
🧰 Tools
🪛 zizmor (1.25.2)

[error] 53-53: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)

(unpinned-uses)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pypi-release.yml around lines 52 - 53, The Publish step
uses a branch reference (`@release/v1`) for the pypa/gh-action-pypi-publish
action, which poses a supply chain security risk since the workflow has
id-token: write permissions. Replace the branch reference with a pinned commit
SHA hash to ensure the exact version of the action is always used and prevent
upstream compromise.

Source: Linters/SAST tools

@AdishAssain
AdishAssain merged commit 5cc744c into main Jun 15, 2026
3 checks passed
@AdishAssain
AdishAssain deleted the fix/pypi-trusted-publishing branch June 15, 2026 15:30
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

Successfully merging this pull request may close these issues.

1 participant