Skip to content

Publish to PyPI from GitHub releases via Trusted Publishing - #6

Merged
mdepinet merged 4 commits into
mainfrom
mike/claude-publish-workflow
Jul 18, 2026
Merged

Publish to PyPI from GitHub releases via Trusted Publishing#6
mdepinet merged 4 commits into
mainfrom
mike/claude-publish-workflow

Conversation

@mdepinet

@mdepinet mdepinet commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Publishing a GitHub release now builds the sdist/wheel and uploads it to PyPI via Trusted Publishing (OIDC — no token or password stored anywhere), after a guard checks the release tag matches setup.py's version (tags here are plain 0.0.6-style, matching the existing ones).

One-time setup only you can do: in the PyPI project settings for hamcrest-protoPublishing, add a GitHub trusted publisher with owner mdepinet, repository hamcrest-proto, workflow publish.yml, environment release. Until that's registered, the upload step will fail with an OIDC error.

The first real run will be the 0.0.7 release (main already carries the version bump from #5): create a GitHub release with tag 0.0.7 and this workflow does the rest. That run is also the workflow's first live test — the sed version-guard and build steps I verified locally, but the upload leg can only be proven by an actual release.

Replaces the uncommitted PUBLISHING.md twine flow as the durable directions.

🤖 Generated with Claude Code

Mike Depinet (using Claude) and others added 2 commits July 18, 2026 12:08
Publishing a GitHub release builds the sdist/wheel and uploads to PyPI
with OIDC (no stored credentials), after checking the release tag
matches setup.py's version.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Adds an automated GitHub Actions publishing workflow so that creating a GitHub Release builds sdist/wheel and uploads to PyPI using PyPI Trusted Publishing (OIDC), with a guard that the release tag matches setup.py’s version.

Changes:

  • Introduces a Publish workflow triggered on release.published.
  • Verifies the release tag equals the version in setup.py before building.
  • Builds distributions and publishes to PyPI via pypa/gh-action-pypi-publish using OIDC.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/publish.yml
Copilot flagged that the job-level permissions block left the checkout
without contents: read (harmless on a public repo today, but implicit).
Restructure into the shape the PyPA publish action recommends: a build
job with contents: read producing the dist artifact, and a publish job
holding only id-token: write, so no repository-controlled code runs
while the Trusted Publishing OIDC token is available.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

.github/workflows/publish.yml:43

  • The publish job restricts token permissions to only id-token: write. actions/download-artifact@v4 uses the GitHub Actions API to fetch the artifact and typically requires actions: read; with the current permissions it may fail to download the dist artifact.
    needs: build
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@v4
        with:

Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@mdepinet
mdepinet merged commit 44bd93b into main Jul 18, 2026
6 checks passed
@mdepinet
mdepinet deleted the mike/claude-publish-workflow branch July 18, 2026 19:52
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