INNER CODE UNIT · Python
update_yaml_version
jpush/jpush-react-native · .claude/skills/update-sdk/scripts/plugin_updater.py:122
def update_yaml_version(file_path: str, new_version: str) -> bool:
"""Update 'version:' line in a YAML file."""
path = Path(file_path)
if not path.exists():
print(f" WARNING: File not found: {file_path}")
return False
content = path.read_text(encoding="utf-8")
match = re.search(r"^(version:\s*)(.+)$", content, re.MULTILINE)
if not match:
print(f" WARNING: No 'version:' field found in {file_path}")
return False
old_version = match.group(2).strip()
if old_version == new_version:
print(f" SKIP: {file_path} already at {new_version}")
return True