|
| 1 | +# Releasing sdr_dsp |
| 2 | + |
| 3 | +How a version gets from `main` to PyPI. The mechanics live in |
| 4 | +`.github/workflows/release.yml`; this is the human checklist around it. The |
| 5 | +package is published as `sdr-dsp` (PyPI normalises the underscore). |
| 6 | + |
| 7 | +## One-time setup (before the first release) |
| 8 | + |
| 9 | +1. **Register the PyPI project and its trusted publisher.** On pypi.org, logged |
| 10 | + in as the owner: *Your projects → Publishing → Add a new pending publisher*: |
| 11 | + - PyPI project name: `sdr-dsp` |
| 12 | + - Owner: `LC-Linkous` Repository: `sdr_dsp_python` |
| 13 | + - Workflow name: `release.yml` Environment name: `pypi` |
| 14 | + |
| 15 | + This is OIDC "trusted publishing": GitHub proves to PyPI which workflow is |
| 16 | + running, and PyPI issues a short-lived token for that run. **No API token |
| 17 | + is created, stored, or rotated.** The pending publisher becomes the real |
| 18 | + one on the first successful publish. |
| 19 | +2. **Create the `pypi` environment** in the repo: *Settings → Environments → |
| 20 | + New environment → `pypi`*. Optionally add yourself as a required reviewer: |
| 21 | + then every publish waits for one click, which is cheap insurance against a |
| 22 | + mistyped tag. |
| 23 | +3. (Optional) Do the same on **test.pypi.org** and run the workflow once with |
| 24 | + `repository-url: https://test.pypi.org/legacy/` added to the publish step, |
| 25 | + to see the whole path work before it is public. Remove the line after. |
| 26 | + |
| 27 | +## Per release |
| 28 | + |
| 29 | +1. **Pick the version.** While the major is 0, a minor bump (`0.x.0`) is any |
| 30 | + release where a public function's behaviour or signature changed -- a new |
| 31 | + `raise` on previously accepted input counts. A patch bump (`0.3.x`) is |
| 32 | + fixes that no correct caller can observe. |
| 33 | +2. **Edit `sdr_dsp/pyproject.toml`**: `version = "X.Y.Z"`. This is the only |
| 34 | + place the version lives; `sdr_dsp.__version__` reads it from the installed |
| 35 | + metadata, and the release workflow refuses a tag that does not match it. |
| 36 | + If the development status changed, update the classifier. |
| 37 | +3. **Roll `CHANGELOG.md`**: rename `## [Unreleased]` to `## [X.Y.Z] - YYYY-MM-DD` |
| 38 | + with a short summary paragraph on top (what kind of release this is, in |
| 39 | + three or four sentences), and open a fresh empty `## [Unreleased]` above it. |
| 40 | +4. **Run the gates locally** from `sdr_dsp/` -- the same ones CI runs: |
| 41 | + ```sh |
| 42 | + uv lock --check |
| 43 | + uv run pytest -q |
| 44 | + uv run ruff check . ../docs/dev_handbook |
| 45 | + uv run mypy |
| 46 | + uv run python ../docs/dev_handbook/generate_api_handbook.py --check ../docs/dev_handbook/sdr_dsp_API_HANDBOOK.md |
| 47 | + uv build && uv run --with twine twine check dist/* |
| 48 | + ``` |
| 49 | +5. **Commit and push to `main`; wait for `tests.yml` to go green** on the |
| 50 | + full matrix. The release workflow re-runs the suite on one cell, not the |
| 51 | + matrix, so the matrix run on `main` is the real multi-platform gate. |
| 52 | +6. **Tag and push the tag:** |
| 53 | + ```sh |
| 54 | + git tag -a vX.Y.Z -m "sdr_dsp X.Y.Z" |
| 55 | + git push origin vX.Y.Z |
| 56 | + ``` |
| 57 | + `release.yml` then: checks the tag against `pyproject`, re-runs |
| 58 | + suite/ruff/mypy/handbook on the tagged commit, builds, `twine check`s, |
| 59 | + verifies the sdist holds only `src/`, LICENSE, README and `pyproject`, |
| 60 | + publishes, and attaches the wheel and sdist to a GitHub release for the |
| 61 | + tag. If the `pypi` environment has a reviewer, approve it in the Actions |
| 62 | + tab when it pauses. |
| 63 | +7. **Confirm:** `pip install sdr-dsp==X.Y.Z` in a fresh venv; |
| 64 | + `python -c "import sdr_dsp; print(sdr_dsp.__version__)"`. |
| 65 | +8. **After the first release only:** remove the "once the first PyPI release |
| 66 | + is cut" hedges in `README.md` and `sdr_dsp/README.md`. |
| 67 | + |
| 68 | +## Things that are deliberately NOT part of a code release |
| 69 | + |
| 70 | +- **The raw reference captures** (`sample_data/hackrf_one/*.iq`, 160 MB) are |
| 71 | + release assets on their own tag (`v0.3.0-captures`, the `DEFAULT_RELEASE` |
| 72 | + in `tools/fetch_sample_data.py`). They change when a capture is re-taken, |
| 73 | + not when code changes, so they are not re-uploaded per version. To publish |
| 74 | + a new set: `gh release create vX.Y.Z-captures sdr_dsp/sample_data/hackrf_one/*.iq`, |
| 75 | + update `DEFAULT_RELEASE`, and make sure each payload's `sdr_dsp:sha256` in |
| 76 | + its sidecar matches (`tools/fetch_sample_data.py --check`). |
| 77 | +- **The API handbook** is regenerated and committed as part of the change |
| 78 | + that alters the API, not at release time; CI fails if it is stale. |
| 79 | + |
| 80 | +## If a release goes wrong |
| 81 | + |
| 82 | +- A tag pushed by mistake before `main` was ready: delete it |
| 83 | + (`git push --delete origin vX.Y.Z`) **before** the publish job runs or is |
| 84 | + approved. Once a version is on PyPI it cannot be re-uploaded; the fix is |
| 85 | + the next patch version, and `pip`'s view of the bad one can be hidden with |
| 86 | + *yank* on pypi.org (it stays installable by exact pin, which is what you |
| 87 | + want for anyone who already locked it). |
| 88 | +- The workflow refused the tag: the version in `pyproject.toml` and the tag |
| 89 | + disagree. Fix `pyproject`, commit, re-tag. |
0 commit comments