Skip to content

chore: publish to PyPI with trusted publishing - #305

Merged
shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-huu4p1
Oct 22, 2026
Merged

shenxianpeng merged 2 commits into
mainfrom
claude/project-thread-huu4p1

Conversation

@shenxianpeng

@shenxianpeng shenxianpeng commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Summary

Publishing used long-lived PYPI_API_TOKEN / TEST_PYPI_TOKEN secrets, passed with secrets: inherit to the shared cpp-linter/.github py-publish.yml@main. This PR builds and publishes from this repository instead, with PyPI trusted publishing (OIDC), so no PyPI token has to be stored. This is the same setup cpp-linter and ccache-wheel use.

  • build job: same wheel build and twine check as before, plus the build provenance attestation (contents: read, id-token: write, attestations: write).
  • publish-pypi: runs on a published release, in the pypi environment, id-token: write only.
  • publish-testpypi: runs on a manual run on main, in the testpypi environment. Same trigger as before.
  • All actions pinned to commit SHAs.

Before merging (maintainer)

  1. On PyPI, project cpp-linter-hooks → Settings → Publishing → add a GitHub publisher: owner cpp-linter, repository cpp-linter-hooks, workflow publish.yml, environment pypi. Do the same on TestPyPI with environment testpypi.
  2. In this repo, Settings → Environments: create pypi (required reviewer, deployment tags only) and testpypi.
  3. After the first release publishes, delete the old API tokens on PyPI/TestPyPI and remove PYPI_API_TOKEN and TEST_PYPI_TOKEN from this repo's secrets.

Related Issues

None.

Summary by CodeRabbit

  • Chores
    • Package builds are now checked before publication, and build provenance is included with uploaded distributions.
    • Publishing to TestPyPI and PyPI now follows separate workflows with restricted triggers and trusted publishing. TestPyPI uploads skip versions that already exist.

Publishing used long-lived PyPI and TestPyPI API tokens, passed with
'secrets: inherit' to a shared workflow on cpp-linter/.github@main.
Build and publish in this repository instead, with OIDC trusted
publishing from the 'pypi' and 'testpypi' environments, so no PyPI
token needs to be stored. Releases still go to PyPI and manual runs on
main still go to TestPyPI.
@shenxianpeng shenxianpeng self-assigned this Oct 22, 2026
@codecov

codecov Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ae4e8b3) to head (d6e36b1).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #305   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          347       347           
=========================================
  Hits           347       347           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d7e96eb9-34b0-4761-884f-549f146b2407
📥 Commits

Reviewing files that changed from the base of the PR and between 0a4d45a and d6e36b1.

📒 Files selected for processing: 1
  • .github/workflows/publish.yml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 17615542-75ba-4a6f-8a58-acf90196dbc9
📥 Commits

Reviewing files that changed from the base of the PR and between ae4e8b3 and 0a4d45a.

📒 Files selected for processing: 1
  • .github/workflows/publish.yml

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The publishing workflow builds and checks a wheel, attests its provenance, and uploads the distribution. It then publishes to TestPyPI for qualifying manual runs or to PyPI for qualifying published releases.

Changes

Package publishing workflow

Layer / File(s) Summary
Build and attest distribution
.github/workflows/publish.yml
The build job checks out the repository, builds and checks a wheel, attests its provenance, and uploads the distribution artifact.
Publish to package indexes
.github/workflows/publish.yml
The workflow adds a TestPyPI job for manual dispatches on main and a PyPI job for published tag releases. Both jobs download the artifact and use OIDC permissions and their respective GitHub environments.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Merge Risk: ⚪ Minimal · up to 0a4d4

The publishing workflow is ready to merge after normal checks and the requested trusted-publisher and environment configuration.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main change: replacing token-based publishing with trusted publishing for PyPI. It is concise and directly related to the workflow changes.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread .github/workflows/publish.yml Resolved
Comment thread .github/workflows/publish.yml Resolved
@shenxianpeng
shenxianpeng merged commit eb39e0f into main Oct 22, 2026
30 checks passed
@shenxianpeng
shenxianpeng deleted the claude/project-thread-huu4p1 branch October 22, 2026 18:41
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.

2 participants