Skip to content

Commit 79eb534

Browse files
committed
prep for pypi release pt 1
1 parent 0a491d8 commit 79eb534

6 files changed

Lines changed: 241 additions & 4 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# Publish sdr_dsp to PyPI when a version tag is pushed.
2+
#
3+
# git tag v0.3.0 && git push origin v0.3.0
4+
#
5+
# What it guards:
6+
# * the tag must equal the version in sdr_dsp/pyproject.toml (a v0.3.1 tag on
7+
# a 0.3.0 tree is refused before anything is built);
8+
# * the suite, ruff and mypy run once more on the tagged commit -- tags are
9+
# cut from a green main, but this is the commit that ships;
10+
# * the built wheel and sdist pass `twine check` (PyPI's own metadata rules)
11+
# and contain only the package (no sample_data/, examples/, tools/).
12+
#
13+
# How it authenticates: PyPI "trusted publishing" (OIDC). There is no API
14+
# token anywhere in this repo or its secrets. ONE-TIME SETUP on pypi.org,
15+
# before the first tag: Your projects -> Publishing -> add a pending publisher
16+
# with owner LC-Linkous, repository sdr_dsp_python, workflow release.yml,
17+
# environment pypi. docs/RELEASING.md has the full checklist.
18+
#
19+
# The two jobs are split so the `pypi` environment (which you can protect with
20+
# a required reviewer in repo Settings -> Environments) only wraps the publish
21+
# step, not the tests.
22+
23+
name: release
24+
25+
on:
26+
push:
27+
tags: ["v*"]
28+
29+
permissions:
30+
contents: read
31+
32+
jobs:
33+
build:
34+
name: verify and build
35+
runs-on: ubuntu-latest
36+
defaults:
37+
run:
38+
working-directory: sdr_dsp
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- uses: astral-sh/setup-uv@v6
43+
with:
44+
enable-cache: true
45+
cache-dependency-glob: sdr_dsp/uv.lock
46+
47+
- name: Tag matches pyproject version
48+
run: |
49+
set -e
50+
tag="${GITHUB_REF_NAME#v}"
51+
ver="$(uv run --no-project --python 3.12 python -c 'import tomllib;print(tomllib.load(open("pyproject.toml","rb"))["project"]["version"])')"
52+
echo "tag=$tag pyproject=$ver"
53+
test "$tag" = "$ver" || { echo "::error::tag v$tag does not match pyproject version $ver"; exit 1; }
54+
55+
- name: Sync (locked)
56+
run: uv sync --locked --python 3.12
57+
58+
- name: Suite, ruff, mypy, handbook on the tagged commit
59+
run: |
60+
uv run pytest -q
61+
uv run ruff check . ../docs/dev_handbook
62+
uv run mypy
63+
uv run python ../docs/dev_handbook/generate_api_handbook.py --check ../docs/dev_handbook/sdr_dsp_API_HANDBOOK.md
64+
65+
- name: Build wheel and sdist
66+
run: uv build
67+
68+
- name: Artifacts contain the package only
69+
run: |
70+
set -e
71+
uv run --with twine twine check dist/*
72+
# anything outside src/, LICENSE*, README.md, pyproject.toml, PKG-INFO is a packaging regression
73+
bad="$(tar tzf dist/*.tar.gz | sed 's|^[^/]*/||' | grep -Ev '^(src(/|$)|LICENSE|README\.md$|pyproject\.toml$|PKG-INFO$)' || true)"
74+
if [ -n "$bad" ]; then echo "::error::unexpected files in sdist:"; echo "$bad"; exit 1; fi
75+
ls -la dist/
76+
77+
- uses: actions/upload-artifact@v4
78+
with:
79+
name: dist
80+
path: sdr_dsp/dist/
81+
if-no-files-found: error
82+
83+
publish:
84+
name: publish to PyPI
85+
needs: build
86+
runs-on: ubuntu-latest
87+
environment:
88+
name: pypi
89+
url: https://pypi.org/project/sdr-dsp/
90+
permissions:
91+
id-token: write # trusted publishing
92+
contents: write # attach the artifacts to the GitHub release
93+
steps:
94+
- uses: actions/download-artifact@v4
95+
with:
96+
name: dist
97+
path: dist/
98+
99+
- name: Publish
100+
uses: pypa/gh-action-pypi-publish@release/v1
101+
with:
102+
packages-dir: dist/
103+
print-hash: true
104+
105+
- name: Attach artifacts to the GitHub release
106+
uses: softprops/action-gh-release@v2
107+
with:
108+
files: dist/*
109+
generate_release_notes: false
110+
body: |
111+
`pip install sdr-dsp` -- what changed is in
112+
[CHANGELOG.md](https://github.com/LC-Linkous/sdr_dsp_python/blob/main/CHANGELOG.md).

‎CHANGELOG.md‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,39 @@ was measured, why a design went the way it did) lives in `docs/LOG.md`.
1010

1111
## [Unreleased]
1212

13+
## [0.3.0] - 2026-11-08
14+
15+
First release on PyPI (`pip install sdr-dsp`), and the first one that was
16+
reviewed rather than only tested. The headline is correctness: a review and
17+
mutation pass over the 0.2.0 suite found six runtime bugs under a green suite
18+
(AGC poisoning its output with NaN after silence and collapsing after a level
19+
step; a timing loop that could not track a symbol-rate error and an early-late
20+
detector that was dead; a Costas loop that depended on signal amplitude; a PSD
21+
that returned a silent -200 dB floor on short input; a pipeline that dropped
22+
the resampler's tail), and the tests that had let them through were rewritten
23+
so that each of those bugs now fails a test. Every recovery loop has a
24+
measured, documented pull-in range and lock time. Several functions now raise
25+
where they used to return something plausible and wrong (`psd`, `fm_demod`,
26+
`resample_poly`, `deemphasis`), which is why this is 0.3 and not 0.2.1.
27+
28+
For downstream consumers: `psd(scaling="dbfs")`, `StreamingPSD`, a
29+
machine-readable `capture_health` verdict, SigMF sidecars and a fetch script
30+
for the raw reference captures (which have left git), and a verified wheel +
31+
sdist that contain the package only. The docs were consolidated (one README,
32+
one TODO, one HAL document) and the API handbook is generated and gated in CI.
33+
Development status moves from Alpha to Beta: the software path is complete and
34+
defended; only FM has been validated against real RF, and that is the next
35+
phase.
36+
37+
### Added (release machinery)
38+
- `.github/workflows/release.yml`: on a `v*` tag, checks the tag against
39+
`pyproject.toml`, re-runs suite/ruff/mypy/handbook on the tagged commit,
40+
builds, `twine check`s, verifies the sdist holds the package only, publishes
41+
to PyPI via trusted publishing (no stored token) and attaches the artifacts
42+
to the GitHub release. `docs/RELEASING.md` is the checklist around it.
43+
- `pyproject.toml`: Development Status Alpha -> Beta; `Changelog` and
44+
`Documentation` project URLs.
45+
1346
### Added (for downstream consumers, hackrf-web 0.3)
1447
- `psd(..., scaling="density" | "dbfs")`. Default "density" is unchanged
1548
(power/Hz). "dbfs" divides by sum(window)^2 so a full-scale complex tone on

‎docs/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Start at the quickstart: [`../sdr_dsp/README.md`](../sdr_dsp/README.md)
1818

1919
| File | Who it is for |
2020
|---|---|
21-
| [`../CONTRIBUTING.md`](../CONTRIBUTING.md) | Anyone filing a bug, sharing a capture, or sending a small PR. |
21+
| [`../CONTRIBUTING.md`](../CONTRIBUTING.md) | Anyone filing a bug, sharing a capture, or wondering why PRs are closed for now. |
2222
| [`ADDING_AN_SDR.md`](ADDING_AN_SDR.md) | Anyone pointing the library at a radio other than the HackRF: the `IQSource`/`TXSink` seam, the porting process and record. |
2323
| [`dev_handbook/`](dev_handbook/) | Generated API handbook plus the scripts that produce it (CI checks it is current). |
2424

@@ -27,6 +27,7 @@ Start at the quickstart: [`../sdr_dsp/README.md`](../sdr_dsp/README.md)
2727
| File | Who it is for |
2828
|---|---|
2929
| [`TODO.md`](TODO.md) | Open work in priority order, plus known limitations. The LOG's deferrals live here. |
30+
| [`RELEASING.md`](RELEASING.md) | The maintainer, cutting a version: one-time PyPI setup, the per-release checklist, what is not part of a release. |
3031
| [`LOG.md`](LOG.md) | The dated development log, newest first: what was tried, measured, and why. |
3132
| [`notes/`](notes/) | One-off investigation notes (currently the packet-capture converter note). |
3233

‎docs/RELEASING.md‎

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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.

‎sdr_dsp/pyproject.toml‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "sdr_dsp"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
description = "A device-agnostic digital signal processing library for software-defined radio IQ."
55
readme = "README.md"
66
requires-python = ">=3.11"
@@ -9,7 +9,7 @@ license-files = ["LICENSE*"]
99
authors = [{ name = "LC-Linkous" }]
1010
keywords = ["sdr", "dsp", "iq", "radio", "signal-processing", "hackrf"]
1111
classifiers = [
12-
"Development Status :: 3 - Alpha",
12+
"Development Status :: 4 - Beta",
1313
"Intended Audience :: Science/Research",
1414
"Programming Language :: Python :: 3.11",
1515
"Programming Language :: Python :: 3.12",
@@ -32,6 +32,8 @@ dependencies = [
3232
Homepage = "https://github.com/LC-Linkous/sdr_dsp_python"
3333
Repository = "https://github.com/LC-Linkous/sdr_dsp_python"
3434
Issues = "https://github.com/LC-Linkous/sdr_dsp_python/issues"
35+
Changelog = "https://github.com/LC-Linkous/sdr_dsp_python/blob/main/CHANGELOG.md"
36+
Documentation = "https://github.com/LC-Linkous/sdr_dsp_python/blob/main/docs/README.md"
3537

3638
[project.optional-dependencies]
3739
# These extras are for DOWNSTREAM INSTALLS of the library (pip install

‎sdr_dsp/uv.lock‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)