Seed/update .ci pipeline from manifest-updater v1.1.2
This commit is contained in:
@@ -146,6 +146,29 @@ def parse_readme_sections(repo_root: str) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def screenshot_captions(repo_root: str) -> dict:
|
||||
"""Numbered captions from the readme `== Screenshots ==` block (N -> caption)."""
|
||||
for name, body in parse_readme_sections(repo_root).items():
|
||||
if section_key(name) == "screenshots":
|
||||
caps = {}
|
||||
for line in body.splitlines():
|
||||
m = re.match(r"^\s*(\d+)\.\s+(.*\S)", line)
|
||||
if m:
|
||||
caps[int(m.group(1))] = m.group(2).strip()
|
||||
return caps
|
||||
return {}
|
||||
|
||||
|
||||
def build_screenshots(urls: dict, repo_root: str) -> dict:
|
||||
"""Pair release-provided screenshot URLs {N: src} with the readme's numbered
|
||||
captions into the WP `screenshots` field ({N: {src, caption}})."""
|
||||
caps = screenshot_captions(repo_root)
|
||||
return {
|
||||
str(n): {"src": urls[str(n)], "caption": caps.get(n, "")}
|
||||
for n in sorted(int(k) for k in urls)
|
||||
}
|
||||
|
||||
|
||||
def build_sections(base: dict, repo_root: str, autogen: bool, strip_cfg) -> dict:
|
||||
resolved = {}
|
||||
# 1. curated overrides (.mu-manifest.yaml sections).
|
||||
@@ -168,6 +191,8 @@ def build_sections(base: dict, repo_root: str, autogen: bool, strip_cfg) -> dict
|
||||
# 2. readme.txt == Section == blocks (the WP-native default).
|
||||
for name, body in parse_readme_sections(repo_root).items():
|
||||
key = section_key(name)
|
||||
if key == "screenshots":
|
||||
continue # not a text tab — handled as the `screenshots` gallery.
|
||||
if key not in resolved:
|
||||
resolved[key] = md_section(wporg_subheads(body), key, strip_cfg)
|
||||
# 3. changelog fallback -> CHANGELOG.md.
|
||||
@@ -203,6 +228,7 @@ def main() -> None:
|
||||
sys.exit(f"build-manifest: {BASE_FILE} must be a mapping")
|
||||
|
||||
computed = json.load(open(args.computed, encoding="utf-8"))
|
||||
shots = computed.pop("_screenshots", None) # {N: src} from release.sh (channel URLs)
|
||||
sections = build_sections(base, repo_root, autogen, strip_cfg)
|
||||
|
||||
result = dict(computed)
|
||||
@@ -212,6 +238,8 @@ def main() -> None:
|
||||
result[k] = v
|
||||
if sections:
|
||||
result["sections"] = sections
|
||||
if shots:
|
||||
result["screenshots"] = build_screenshots(shots, repo_root)
|
||||
|
||||
with open(args.out, "w", encoding="utf-8") as fh:
|
||||
json.dump(result, fh, indent=2, ensure_ascii=False)
|
||||
|
||||
Reference in New Issue
Block a user