ci: add an optional TestPyPI dry-run release workflow - #196
Merged
Merged
Conversation
A manual workflow rehearses a release without touching real PyPI or storing tokens: it builds the current commit as a unique X.Y.Z.dev<run><attempt> version (TestPyPI never accepts re-uploads), publishes it to TestPyPI with Trusted Publishing (OIDC, environment `testpypi`), then installs it from TestPyPI in a clean venv with retries, imports it, prints fd.__version__ and asserts it matches, and runs a tiny fd.clean smoke. RELEASE.md documents the workflow, the manual verification command and the one-time maintainer setup (TestPyPI pending publisher + `testpypi` environment). A contract test pins the dispatch-only trigger, OIDC-only publishing to test.pypi.org and the version print.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6.
Summary
The release checklist says "Publish to TestPyPI, smoke-test the install", but the only documented route was a manual
twine uploadwith an API token. This adds a manual, token-free dry run..github/workflows/testpypi.yml(workflow_dispatchonly)pyproject.tomland stamps a uniqueX.Y.Z.dev<run_number><run_attempt>intopyproject.tomlandsrc/freshdata/__init__.py. This only affects the CI checkout; nothing is committed. TestPyPI rejects re-uploading a version, so every run needs its own. The job validates the version withpackaging, then runspython -m buildandtwine check.testpypi,id-token: write, andpypa/gh-action-pypi-publish(already SHA-pinned inrelease.yml) withrepository-url: https://test.pypi.org/legacy/. It uses Trusted Publishing (OIDC), so there are no secrets or tokens.freshdata-cleaner==<dev version>fromhttps://test.pypi.org/simple/(with PyPI as the extra index for dependencies), retrying up to 10×30s while the index catches up. It then runspython -c "import freshdata as fd; print(fd.__version__)", asserts the output equals the published version, and runs the same tinyfd.cleansmoke asrelease.yml.The workflow is limited to
FreshCode-Org/freshdata, and it never touches production PyPI orrelease.yml.RELEASE.mdpip install --index-url https://test.pypi.org/simple/ … && python -c "import freshdata as fd; print(fd.__version__)"), and the one-time setup.twineflow stays as the labelled fallback.Maintainer action required before the first run
The workflow will fail at the publish step until someone with admin access:
freshdata-cleaner, ownerFreshCode-Org, repositoryfreshdata, workflowtestpypi.yml, environmenttestpypi.testpypienvironment under repository Settings → Environments. It needs no secrets.Because of that, I haven't dispatched it yet.
Tests
New
tests/test_testpypi_workflow.py:workflow_dispatch.id-token: write, thetestpypienvironment andtest.pypi.org/legacy/, with nopasswordand nosecrets.anywhere in the file.test.pypi.org/simple/and printsfd.__version__.RELEASE.mdcontains the verification command.Results: 4 passed on Python 3.12 and on 3.9.
ruff checkis clean, and the workflow parses as YAML.