- add tools/release/package.py: sorted, commit-timestamped, uid/gid-normalised deterministic archive; refuses dirty trees, source-SHA mismatch and stale versions; emits SOURCE_SHA, FILES.sha256 and RELEASE_INFO.json with binaries, protocol revisions, core baseline and manifest digest - add tools/release/smoke.py: verifies checksum/manifest/source/version then cold-installs the archive through a real core CLI into an isolated MARQDO_TOOL_HOME and exercises help/compile/query/check/remove, writing smoke evidence - add tools/ci/test_release_metadata.py: single CI gate for version/fact consistency across Cargo files, tool.json, spec, CHANGELOG, release notes, README and CI configuration - Woodpecker and GitHub pipelines now run the metadata gate and use the Python packager/smoke test in the tag-only release lane; shell release scripts are thin wrappers; docs/ci.md and docs/releasing.md document gates and non-gates
89 lines
3.3 KiB
Python
Executable File
89 lines
3.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Metadata consistency gate for the beta release.
|
|
|
|
Checks that the tool version, Cargo files, tool manifest, public spec, changelog,
|
|
release notes and CI configuration describe the same facts. This is a
|
|
documentation/contract gate, not a functional test.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import re
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
|
def fail(message: str) -> "NoReturn":
|
|
print(f"release-metadata: FAIL: {message}", file=sys.stderr)
|
|
raise SystemExit(1)
|
|
|
|
|
|
def main() -> int:
|
|
cargo = (ROOT / "Cargo.toml").read_text(encoding="utf-8")
|
|
match = re.search(r'(?m)^version\s*=\s*"([^"]+)"', cargo)
|
|
if not match:
|
|
fail("Cargo.toml has no version")
|
|
version = match.group(1)
|
|
if not re.fullmatch(r"\d+\.\d+\.\d+-beta\.\d+", version):
|
|
fail(f"version {version} is not a beta semver (expected x.y.z-beta.N)")
|
|
lock = (ROOT / "Cargo.lock").read_text(encoding="utf-8")
|
|
if not re.search(
|
|
r'\[\[package\]\]\nname = "marqdo-knowledge"\nversion = "' + re.escape(version) + r'"',
|
|
lock,
|
|
):
|
|
fail("Cargo.lock version does not match Cargo.toml")
|
|
|
|
tool = json.loads((ROOT / "packaging/tool.json").read_text(encoding="utf-8"))
|
|
expected = {
|
|
"schema": "marqdo.cli-tool",
|
|
"schema_version": 1,
|
|
"name": "marqdo-knowledge",
|
|
"version": version,
|
|
"command": "knowledge",
|
|
"entrypoint": "bin/marqdo-knowledge",
|
|
"requires": {"api_revision": 1, "analysis": 3},
|
|
}
|
|
if tool != expected:
|
|
fail(f"packaging/tool.json is not the current exact manifest: {tool}")
|
|
|
|
spec = (ROOT / "spec/knowledge.md").read_text(encoding="utf-8")
|
|
if f'"version": "{version}"' not in spec:
|
|
fail("spec/knowledge.md tool identity version is stale")
|
|
if '"requires": {"api_revision": 1, "analysis": 3}' not in spec:
|
|
fail("spec/knowledge.md requirements are stale")
|
|
|
|
changelog = (ROOT / "CHANGELOG.md").read_text(encoding="utf-8")
|
|
if f"## {version}" not in changelog:
|
|
fail("CHANGELOG.md has no section for this version")
|
|
notes = ROOT / "docs/releases" / f"{version}.md"
|
|
if not notes.is_file():
|
|
fail(f"missing docs/releases/{version}.md")
|
|
body = notes.read_text(encoding="utf-8")
|
|
for heading in ("What is complete in this beta", "What is NOT complete in this beta", "Compatibility and upgrade notes"):
|
|
if heading not in body:
|
|
fail(f"release notes are missing section `{heading}`")
|
|
|
|
readme = (ROOT / "README.md").read_text(encoding="utf-8")
|
|
if version not in readme:
|
|
fail("README.md does not mention the current version")
|
|
|
|
for configuration in (".woodpecker/main.yml", ".github/workflows/ci.yml"):
|
|
text = (ROOT / configuration).read_text(encoding="utf-8")
|
|
if "tools/release/package.py" not in text:
|
|
fail(f"{configuration} does not use the deterministic packager")
|
|
if "tools/release/smoke.py" not in text:
|
|
fail(f"{configuration} does not run the archive smoke test")
|
|
|
|
ci_docs = (ROOT / "docs/ci.md").read_text(encoding="utf-8")
|
|
if "NOT RUN" not in ci_docs:
|
|
fail("docs/ci.md must state the non-gated items")
|
|
print(f"release-metadata: OK (version {version})")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|