Skip to content

ci: publish to PyPI with trusted publishing and attestations - #27

Merged
Bonajo merged 1 commit into
mainfrom
ci/trusted-publishing
Nov 15, 2026
Merged

Bonajo merged 1 commit into
mainfrom
ci/trusted-publishing

Conversation

@Bonajo

@Bonajo Bonajo commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Publish with PyPI Trusted Publishing instead of the PYPI_TOKEN secret, and upload PEP 740 attestations with every file.

Why the workflows are merged

PyPI only accepts attestations from Trusted Publishing, and it doesn't accept a reusable workflow as a trusted publisher. So the reusable pypi-publish.yml and its two callers (semantic-release.yml and the manual-tag release.yml) are now a single top-level release.yml:

  • push to main → semantic-release (unchanged) → build → publish, run only if a version was cut
  • a v* tag pushed by a human → build → publish (the escape hatch; still no GitHub release)

Build and publish are separate jobs, so only the job that uploads gets id-token: write. That job runs in the new pypi environment, which only allows main and v* tags. astral-sh/attest-action (pinned to the commit of v0.0.7) writes the *.publish.attestation files, and uv publish --trusted-publishing always uploads them. The release build no longer uses the setup-uv cache.

The README's Releases section explains how to verify a file and how to release manually.

Before merging

  • Register the trusted publisher on PyPI for codestripper: owner FontysVenlo, repository codestripper, workflow release.yml, environment pypi

After the next fix/feat release

  • The PyPI file page shows "Verified details"
  • Delete the PYPI_TOKEN secret and revoke the token on PyPI. It stays for now as a rollback in case the first trusted-publishing run fails.

This PR is ci:, so merging it cuts no release. The run on main should finish with only the semantic release job.

The existing action pins (checkout@v6, setup-node@v6, semantic-release-action@v6.0.0, setup-uv@v10.1.0) are kept as they are, so this diff only changes how publishing works.

@Bonajo
Bonajo merged commit b233f9e into main Nov 15, 2026
12 checks passed
@Bonajo
Bonajo deleted the ci/trusted-publishing branch November 15, 2026 09:38
Bonajo added a commit that referenced this pull request Nov 15, 2026
`codestripper --help` described `-e, --fail-on-error` as "Fail if an
error occurs during code stripping". The flag does the opposite: it is
`store_false`, so failing is the default and `-e` turns it **off**. The
help text now says "do NOT fail if an error occurs during code
stripping", matching the README table and the wording of `-r`. Behaviour
is unchanged; the flag name stays, because renaming it would break
existing calls.

Tests in `tests/test_main.py`:
- `--help` describes `-e` as not failing. This test fails on `main`.
- Without `-e`, a file with an invalid tag (`MissingClose.java`) raises
`StripError`.
- With `-e`, the same file only logs the error.

Merging this releases **1.3.1**, the first release through Trusted
Publishing with PEP 740 attestations (#27).
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant