Update version_branch.yml

This commit is contained in:
2025-12-23 16:36:37 -06:00
parent 787482ebdd
commit 3178db4625

View File

@@ -320,53 +320,46 @@ jobs:
exit 2 exit 2
fi fi
- name: Bump versions and update manifest dates (targeted, excluding .github) $1 import json
run: | import os
source "$CI_HELPERS" import re
moko_init "Version bump" from pathlib import Path
from collections import defaultdict
from datetime import datetime, timezone
python3 - <<'PY' new_version = (os.environ.get("NEW_VERSION") or "").strip()
import json version_text = (os.environ.get("VERSION_TEXT") or "").strip()
import os report_only = (os.environ.get("REPORT_ONLY") or "").strip().lower() == "true"
import re report_path = (os.environ.get("REPORT_PATH") or "").strip()
from pathlib import Path
from collections import defaultdict
from datetime import datetime, timezone
new_version = (os.environ.get("NEW_VERSION") or "").strip() stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d")
version_text = (os.environ.get("VERSION_TEXT") or "").strip() root = Path(".").resolve()
report_only = (os.environ.get("REPORT_ONLY") or "").strip().lower() == "true"
report_path = (os.environ.get("REPORT_PATH") or "").strip()
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d") header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})")
root = Path(".").resolve() manifest_marker_re = re.compile(r"(?is)<extension\b")
xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)")
header_re = re.compile(r"(?im)(VERSION[ \t]*:[ \t]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})") xml_date_res = [
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 feeds. They are generated at release time. 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
@@ -376,7 +369,7 @@ def should_skip(p: Path) -> bool:
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):
@@ -420,7 +413,7 @@ for p in root.rglob("*"):
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,
@@ -430,17 +423,17 @@ report = {
"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' }}