Skip to content

ci: enable trusted publishing for PyPI#60

Merged
MetinSa merged 5 commits into
mainfrom
copilot/enable-trusted-publishing-for-pypi
Apr 18, 2026
Merged

ci: enable trusted publishing for PyPI#60
MetinSa merged 5 commits into
mainfrom
copilot/enable-trusted-publishing-for-pypi

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 18, 2026

Long-lived PyPI tokens are a supply-chain risk; OIDC-based trusted publishing eliminates them by issuing short-lived credentials scoped to a specific workflow run.

Changes

  • New workflow .github/workflows/publish.yml
    • Triggers on release: published
    • build job: installs Poetry, runs poetry build, uploads dist/ as a workflow artifact
    • publish job: downloads artifact, publishes via pypa/gh-action-pypi-publish using OIDC — no token required
    • Top-level permissions: contents: read; publish job scoped to id-token: write only

Required admin steps (not in this PR)

  1. PyPI → zodipy project → Publishing → add pending publisher:
    • Repo: Cosmoglobe/zodipy, workflow: publish.yml, environment: pypi
  2. GitHub → Settings → Environments → create environment named pypi (add approval gates as desired)

Copilot AI linked an issue Apr 18, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 18, 2026 12:06
Copilot AI changed the title [WIP] Enable trusted publishing for PyPI packages ci: enable trusted publishing for PyPI Apr 18, 2026
Copilot AI requested a review from MetinSa April 18, 2026 12:08
@MetinSa MetinSa requested a review from Copilot April 18, 2026 12:12
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a GitHub Actions workflow to publish the package to PyPI using OIDC “trusted publishing” on GitHub Releases, avoiding long-lived PyPI tokens.

Changes:

  • Introduces publish.yml triggered on release.published.
  • Builds the package with Poetry and transfers dist/ via workflow artifacts.
  • Publishes to PyPI via pypa/gh-action-pypi-publish using OIDC with an environment gate.

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

Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml
Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml Outdated
Comment on lines +7 to +8
permissions:
contents: read
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

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

The workflow-level permissions restricts the GITHUB_TOKEN to contents: read only, which is likely insufficient for actions/upload-artifact / actions/download-artifact (these generally require actions: write/actions: read). Consider either adding the required actions permission at the workflow level, or (more tightly) setting per-job permissions: build job gets actions: write (+ contents: read for checkout) and publish job gets actions: read (+ id-token: write).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

its even better to use permissions: {} at the top level and only add specific permissions at the job level

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(I also don't think this specific permission is needed at all here)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the comments! I let copilot have a go at it before I check it out myself. Do you have a repo with a good setup that you recommend me checking out?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yup. Have a go at neutrinoceros/idefix_cli. It's as simple as they come (but note I don't use poetry).

@MetinSa MetinSa marked this pull request as ready for review April 18, 2026 20:55
@MetinSa MetinSa merged commit e5ae1be into main Apr 18, 2026
10 checks passed
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.

REL/SEC: enabling trusted publishing for PyPI

4 participants