Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ plain HTTP from `https://raw.githubusercontent.com/chunkzero/rpp-registry/main/`

- `plugins/<name>.json`: one file per plugin, edited by hand.
- `index.json`: generated summary (name, description, repository, latest version). Never edit it
directly; run `python3 scripts/registry.py index`.
directly; run `python3 scripts/registry.py index`. `latest` is the newest non-yanked stable
version (no `-` prerelease suffix), so nightlies, alphas, betas and release candidates never
become `latest`. A plugin with no such version is left out of `index.json`.

```json
{
Expand All @@ -34,8 +36,8 @@ containing `rpp.json` with the same `name` and `version`, and only regular files

1. Build the release archive and its hash with `rpp plugin pack`, and upload the archive to a
GitHub release in the plugin repository.
2. Open a PR that appends the version to the `versions` of `plugins/<name>.json` (or adds a new
plugin file) and regenerates the index with `python3 scripts/registry.py index`.
2. Open a PR that adds the version to the `versions` of `plugins/<name>.json` in semver order
(or adds a new plugin file) and regenerates the index with `python3 scripts/registry.py index`.
3. CI runs `python3 scripts/registry.py check --base origin/main`, which downloads each new
archive, verifies its hash and contents, and rejects changes to published versions.

Expand All @@ -47,6 +49,15 @@ Set `"yanked": true` on a version and regenerate `index.json`. Published version
immutable: they cannot be edited, reordered, removed, or un-yanked. A plugin whose versions are
all yanked disappears from `index.json`.

## Prereleases

Prerelease versions are published like any other and sort by semver precedence. Nightlies use
`X.Y.Z-nightly.YYYYMMDDHHMMSS.g<sha12>` (older ones use `X.Y.Z-nightly.YYYYMMDD.g<sha12>`); the
timestamp is a numeric identifier, so each form orders chronologically and every 14-digit nightly
sorts after every 8-digit one of the same version. A beta or rc registered after nightlies of the
same version sorts below or above them by precedence, wherever that falls. Others use
`X.Y.Z-alpha.N`, `-beta.N` or `-rc.N`.

## Development

```
Expand Down
9 changes: 1 addition & 8 deletions index.json
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
[
{
"name": "window",
"description": "Compiles UIs into resource-pack assets and Kotlin bindings. Source commit: 9872875840f74b8bb88bb354970b827edb1c57cc",
"repository": "https://github.com/chunkzero/window",
"latest": "0.1.0-nightly.20261003.g9872875840f7"
}
]
[]
16 changes: 9 additions & 7 deletions scripts/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ def build_index(plugins: dict[str, dict]) -> str:
entries = []
for name in sorted(plugins):
p = plugins[name]
live = [v["version"] for v in p["versions"] if not v.get("yanked", False)]
if live:
latest = max(live, key=semver_key)
# rpp's index.json schema requires a version for `latest`, so plugins without a
# stable release are left out rather than listed with null or a prerelease.
stable = [
v["version"]
for v in p["versions"]
if not v.get("yanked", False) and SEMVER_RE.fullmatch(v["version"]).group(4) is None
]
if stable:
latest = max(stable, key=semver_key)
entries.append(
{
"name": p["name"],
Expand All @@ -153,7 +159,6 @@ def compare_to_base(head: dict, base: dict) -> list[str]:
if head[field] != base.get(field):
errors.append(f"{field} must not change")
head_by_version = {v["version"]: v for v in head["versions"]}
base_versions = [v["version"] for v in base.get("versions", []) if isinstance(v, dict)]
for bv in base["versions"]:
hv = head_by_version.get(bv["version"])
if hv is None:
Expand All @@ -165,9 +170,6 @@ def compare_to_base(head: dict, base: dict) -> list[str]:
errors.append(f"published version {bv['version']}: {f} must not change")
if bv.get("yanked", False) and not hv.get("yanked", False):
errors.append(f"published version {bv['version']}: cannot be un-yanked")
head_versions = [v["version"] for v in head["versions"]]
if head_versions[: len(base_versions)] != base_versions and set(base_versions) <= set(head_versions):
errors.append("new versions must be appended after the published versions")
return errors


Expand Down
29 changes: 25 additions & 4 deletions scripts/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,34 @@ def test_index_orders_and_skips_yanked(self):
self.assertLess(registry.semver_key("1.1.0-rc.1"), registry.semver_key("1.1.0"))
self.assertLess(registry.semver_key("1.2.0"), registry.semver_key("1.10.0"))
self.write([version_entry("1.0.0"), version_entry("1.1.0-rc.1"), version_entry("1.1.0"),
version_entry("1.2.0", yanked=True)], "zeta")
version_entry("1.2.0", yanked=True), version_entry("1.3.0-beta.1")], "zeta")
self.write([version_entry("1.0.0", yanked=True)], "alpha")
self.write([version_entry("0.1.0")], "beta")
self.write([version_entry("0.1.0-alpha.0"), version_entry("0.1.0-nightly.20261003.g9872875840f7")],
"gamma")
index = json.loads((self.root / "index.json").read_text())
self.assertEqual([(e["name"], e["latest"]) for e in index], [("beta", "0.1.0"), ("zeta", "1.1.0")])

def test_nightly_formats_order_and_append(self):
versions = [
"0.1.0-alpha.0",
"0.1.0-beta.2",
"0.1.0-nightly.20261002.g67305fc8e4c3",
"0.1.0-nightly.20261003.g9872875840f7",
"0.1.0-nightly.20261004093000.g12336a991a34",
"0.1.0-nightly.20261004181500.g0123456789ab",
"0.1.0-rc.1",
"0.1.0",
]
keys = [registry.semver_key(v) for v in versions]
self.assertEqual(keys, sorted(keys))
self.write([version_entry(v) for v in versions[2:4]])
self.commit()
archive = make_archive({"name": "widget", "version": versions[4]})
self.serve(versions[4], archive)
self.write([version_entry(v) for v in versions[2:4]] + [version_entry(versions[4], archive)])
self.assertEqual(registry.check(self.root, base="HEAD"), [])

def test_rejects_edited_published_version(self):
self.write([version_entry("1.0.0")])
self.commit()
Expand Down Expand Up @@ -174,14 +196,13 @@ def test_rejects_too_many_entries(self):
errors = registry.validate_archive(archive, "widget", "1.0.0")
self.assertTrue(any("more than 1 entries" in e for e in errors), errors)

def test_rejects_inserted_version(self):
def test_accepts_version_inserted_in_semver_order(self):
self.write([version_entry("1.0.0"), version_entry("1.2.0")])
self.commit()
archive = make_archive({"name": "widget", "version": "1.1.0"})
self.serve("1.1.0", archive)
self.write([version_entry("1.0.0"), version_entry("1.1.0", archive), version_entry("1.2.0")])
problems = registry.check(self.root, base="HEAD")
self.assertTrue(any("must be appended" in p for p in problems), problems)
self.assertEqual(registry.check(self.root, base="HEAD"), [])

def test_semver_is_ascii_and_anchored(self):
self.assertFalse(registry.is_semver("1.0.0\n"))
Expand Down
Loading