Repository navigation
chore(ci): add PyPI trusted publishing workflow - #470
jahirvidrio wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The release smoke test can skip installing the built wheel because leftover nodeenv.egg-info appears already installed, leaving no bin/nodeenv and blocking publication; the install needs --force-reinstall.
1 open issue
What changed in this PR
Adds tag-triggered PyPI trusted publishing for nodeenv, implementing the automation proposed in #416 while keeping release timing under maintainer control.
Changes:
- Checks that the version tag matches
nodeenv_versionbefore building the sdist and wheel. - Validates distribution metadata and adds a wheel installation smoke test.
- Publishes the build artifacts through the
pypienvironment, with SHA-pinned actions and OIDC permission limited to the publish job.
| File | Description |
|---|---|
.github/workflows/release.yml |
Adds separate build-validation and trusted-publishing jobs for version-tag releases. |
Review effort: Balanced
| run: | | ||
| set -euo pipefail | ||
| python -m venv "${RUNNER_TEMP}/smoke" | ||
| "${RUNNER_TEMP}/smoke/bin/python" -m pip install --quiet dist/*.whl |
There was a problem hiding this comment.
I dug into the finding and the conclusion doesn't hold, so I haven't changed anything.
The observation itself is right: python -m build does leave nodeenv.egg-info in the checkout. But that doesn't reach the step in question. We hand pip an explicit wheel path, not the project directory, so the stray egg-info never enters resolution. I reproduced the exact scenario from scratch: working directory with nodeenv.egg-info present, brand new venv, command untouched.
Processing .../dist/nodeenv-1.12.0-py3-none-any.whl
Installing collected packages: nodeenv
Successfully installed nodeenv-1.12.0
$ smoke/bin/nodeenv --version
1.12.0
The entry point lands and reports the right version. And if the install ever were skipped, the job dies instead of publishing something broken: set -euo pipefail plus the version check on the next line mean a missing bin/nodeenv fails the build. That's a loud failure, not a silent one.
On --force-reinstall, I don't think we need it here, so I left it out. Say the word if you'd rather have the flag in anyway, it's one line.

Adds
.github/workflows/release.yml, the trusted publishing workflow discussed in #416. Pushing a bare version tag builds the sdist and wheel withpython -m buildand uploads them to PyPI through OIDC, with no credentials stored in the repository. No other workflow is touched.The guard rails:
pushon tags matching digit.digit.digit triggers it, so an unrelated tag likedocs-2026leaves the workflow alone.id-token: writeis granted to thepublishjob only.buildkeeps the workflow-levelcontents: read.publishruns in thepypienvironment.GITHUB_REF_NAMEwithnodeenv_versionfromnodeenv.py, so a mismatch fails in seconds instead of after the dist is built. If the value cannot be read, the step fails loudly rather than comparing against an empty string.buildrunstwine checkon both artifacts, installs the wheel into a throwaway venv and comparesnodeenv --versionwith the tag. A broken wheel fails the job, andpublishneedsbuild.publishuploads the artifactbuildproduced and checked, nothing else.Tests are not part of this change: it adds one workflow file, and nothing in
tests/covers.github/. I kept the diff torelease.ymlas asked.Fixes #416
toxpasses: the tests and flake8CHANGEShas an entry underVersion [unreleased], if nodeenv'sbehavior changes
README.rstis updated, if the change affects what it documentstype(scope): subject