Update version_branch.yml

This commit is contained in:
2025-12-23 16:41:53 -06:00
parent 3178db4625
commit 0393867caa

View File

@@ -320,46 +320,53 @@ jobs:
exit 2 exit 2
fi fi
$1 import json - name: Bump versions and update manifest dates (targeted, excluding .github)
import os run: |
import re source "$CI_HELPERS"
from pathlib import Path moko_init "Version bump"
from collections import defaultdict
from datetime import datetime, timezone
new_version = (os.environ.get("NEW_VERSION") or "").strip() python3 - <<'PY'
version_text = (os.environ.get("VERSION_TEXT") or "").strip() import json
report_only = (os.environ.get("REPORT_ONLY") or "").strip().lower() == "true" import os
report_path = (os.environ.get("REPORT_PATH") or "").strip() import re
from pathlib import Path
from collections import defaultdict
from datetime import datetime, timezone
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d") new_version = (os.environ.get("NEW_VERSION") or "").strip()
root = Path(".").resolve() version_text = (os.environ.get("VERSION_TEXT") or "").strip()
report_only = (os.environ.get("REPORT_ONLY") or "").strip().lower() == "true"
report_path = (os.environ.get("REPORT_PATH") or "").strip()
header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})") stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d")
manifest_marker_re = re.compile(r"(?is)<extension\b") root = Path(".").resolve()
xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)")
xml_date_res = [ # Use escape sequences only. Do not introduce literal tab characters.
header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})")
manifest_marker_re = re.compile(r"(?is)<extension\b")
xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)")
xml_date_res = [
re.compile(r"(?is)(<creationDate[ \t]*>)([^<]*?)(</creationDate[ \t]*>)"), re.compile(r"(?is)(<creationDate[ \t]*>)([^<]*?)(</creationDate[ \t]*>)"),
re.compile(r"(?is)(<date[ \t]*>)([^<]*?)(</date[ \t]*>)"), re.compile(r"(?is)(<date[ \t]*>)([^<]*?)(</date[ \t]*>)"),
re.compile(r"(?is)(<releaseDate[ \t]*>)([^<]*?)(</releaseDate[ \t]*>)"), re.compile(r"(?is)(<releaseDate[ \t]*>)([^<]*?)(</releaseDate[ \t]*>)"),
] ]
skip_ext = { skip_ext = {
".json", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".pdf", ".json", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".pdf",
".zip", ".7z", ".tar", ".gz", ".woff", ".woff2", ".ttf", ".otf", ".zip", ".7z", ".tar", ".gz", ".woff", ".woff2", ".ttf", ".otf",
".mp3", ".mp4", ".mp3", ".mp4",
} }
skip_dirs = {".git", ".github", "node_modules", "vendor", ".venv", "dist", "build"} skip_dirs = {".git", ".github", "node_modules", "vendor", ".venv", "dist", "build"}
counters = defaultdict(int) counters = defaultdict(int)
updated_files = [] updated_files = []
updated_manifests = [] updated_manifests = []
would_update_files = [] would_update_files = []
would_update_manifests = [] would_update_manifests = []
exclude_root = {"update.xml", "updates.xml"} exclude_root = {"update.xml", "updates.xml"}
def should_skip(p: Path) -> bool: def should_skip(p: Path) -> bool:
if p.suffix.lower() in skip_ext: if p.suffix.lower() in skip_ext:
counters["skipped_by_ext"] += 1 counters["skipped_by_ext"] += 1
return True return True
@@ -369,7 +376,7 @@ jobs:
return True return True
return False return False
for p in root.rglob("*"): for p in root.rglob("*"):
if not p.is_file(): if not p.is_file():
continue continue
if should_skip(p): if should_skip(p):
@@ -413,7 +420,7 @@ jobs:
if is_manifest: if is_manifest:
updated_manifests.append(str(p)) updated_manifests.append(str(p))
report = { report = {
"mode": "report_only" if report_only else "apply", "mode": "report_only" if report_only else "apply",
"new_version": new_version, "new_version": new_version,
"version_text": version_text, "version_text": version_text,
@@ -423,17 +430,17 @@ jobs:
"updated_manifests": updated_manifests, "updated_manifests": updated_manifests,
"would_update_files": would_update_files, "would_update_files": would_update_files,
"would_update_manifests": would_update_manifests, "would_update_manifests": would_update_manifests,
} }
Path(report_path).write_text(json.dumps(report, indent=2), encoding="utf-8") Path(report_path).write_text(json.dumps(report, indent=2), encoding="utf-8")
print("[INFO] Report written to:", report_path) print("[INFO] Report written to:", report_path)
print("[INFO] Mode:", report["mode"]) print("[INFO] Mode:", report["mode"])
print("[INFO] Would update files:", len(would_update_files)) print("[INFO] Would update files:", len(would_update_files))
print("[INFO] Would update manifests:", len(would_update_manifests)) print("[INFO] Would update manifests:", len(would_update_manifests))
print("[INFO] Updated files:", len(updated_files)) print("[INFO] Updated files:", len(updated_files))
print("[INFO] Updated manifests:", len(updated_manifests)) print("[INFO] Updated manifests:", len(updated_manifests))
PY PY
- name: Commit changes - name: Commit changes
if: ${{ env.REPORT_ONLY != 'true' }} if: ${{ env.REPORT_ONLY != 'true' }}