Files
unleashed-firmware/.github/scripts/bump_issue_template_version.py
T
Mykhailo ShevchukandClaude Opus 4.8 eb49a89441 ci: auto-bump issue-template stable version on release publish [ci skip]
Add a workflow that, when a stable `unlshd-*` release is published, rewrites
the bug-report template's "Found in version" dropdown to keep exactly one
stable option (the new release tag) + "dev", then commits it to dev.

- Prerelease/non-unlshd tags are skipped.
- Surgical regex edit (minimal one-line diff), validated with yq before commit.
- Pushes via GITHUB_TOKEN don't retrigger CI; [ci skip] added to match convention.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-05 14:40:29 +03:00

46 lines
1.4 KiB
Python

#!/usr/bin/env python3
"""Set the bug-report template's "Found in version" dropdown to [<release>, dev].
Called by .github/workflows/bump-issue-template-version.yml when a stable
release is published. Does a surgical text edit (minimal one-line diff);
the result is validated in the workflow with yq.
"""
import re
import sys
from pathlib import Path
TEMPLATE = Path(".github/ISSUE_TEMPLATE/01_bug_report.yml")
# Matches the fw-version dropdown's options block and captures the stable
# entry (the line before "- dev") so only that one line gets rewritten:
# options:
# - <stable> <- replaced with the new release tag
# - dev
OPTIONS_RE = re.compile(r"(^\s*options:\n\s*-\s*)[^\n]+(\n\s*-\s*dev\s*$)", re.MULTILINE)
def main() -> int:
if len(sys.argv) != 2 or not sys.argv[1].strip():
print("usage: bump_issue_template_version.py <release-tag>", file=sys.stderr)
return 2
tag = sys.argv[1].strip()
text = TEMPLATE.read_text(encoding="utf-8")
new, n = OPTIONS_RE.subn(lambda m: m.group(1) + tag + m.group(2), text)
if n != 1:
print(
f"::error::expected exactly 1 'options' block ending in 'dev', found {n}",
file=sys.stderr,
)
return 1
if new != text:
TEMPLATE.write_text(new, encoding="utf-8")
print(f"Set Found-in-version stable option to {tag}")
return 0
if __name__ == "__main__":
sys.exit(main())