Update version_branch.yml
This commit is contained in:
83
.github/workflows/version_branch.yml
vendored
83
.github/workflows/version_branch.yml
vendored
@@ -320,46 +320,53 @@ jobs:
|
||||
exit 2
|
||||
fi
|
||||
|
||||
$1 import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timezone
|
||||
- name: Bump versions and update manifest dates (targeted, excluding .github)
|
||||
run: |
|
||||
source "$CI_HELPERS"
|
||||
moko_init "Version bump"
|
||||
|
||||
new_version = (os.environ.get("NEW_VERSION") or "").strip()
|
||||
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()
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
from collections import defaultdict
|
||||
from datetime import datetime, timezone
|
||||
|
||||
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
||||
root = Path(".").resolve()
|
||||
new_version = (os.environ.get("NEW_VERSION") or "").strip()
|
||||
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})")
|
||||
manifest_marker_re = re.compile(r"(?is)<extension\b")
|
||||
xml_version_re = re.compile(r"(?is)(<version[ \t]*>)([^<]*?)(</version[ \t]*>)")
|
||||
xml_date_res = [
|
||||
stamp = datetime.now(timezone.utc).strftime("%Y-%m-%d")
|
||||
root = Path(".").resolve()
|
||||
|
||||
# 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)(<date[ \t]*>)([^<]*?)(</date[ \t]*>)"),
|
||||
re.compile(r"(?is)(<releaseDate[ \t]*>)([^<]*?)(</releaseDate[ \t]*>)"),
|
||||
]
|
||||
]
|
||||
|
||||
skip_ext = {
|
||||
skip_ext = {
|
||||
".json", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".ico", ".pdf",
|
||||
".zip", ".7z", ".tar", ".gz", ".woff", ".woff2", ".ttf", ".otf",
|
||||
".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)
|
||||
updated_files = []
|
||||
updated_manifests = []
|
||||
would_update_files = []
|
||||
would_update_manifests = []
|
||||
counters = defaultdict(int)
|
||||
updated_files = []
|
||||
updated_manifests = []
|
||||
would_update_files = []
|
||||
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:
|
||||
counters["skipped_by_ext"] += 1
|
||||
return True
|
||||
@@ -369,7 +376,7 @@ jobs:
|
||||
return True
|
||||
return False
|
||||
|
||||
for p in root.rglob("*"):
|
||||
for p in root.rglob("*"):
|
||||
if not p.is_file():
|
||||
continue
|
||||
if should_skip(p):
|
||||
@@ -413,7 +420,7 @@ jobs:
|
||||
if is_manifest:
|
||||
updated_manifests.append(str(p))
|
||||
|
||||
report = {
|
||||
report = {
|
||||
"mode": "report_only" if report_only else "apply",
|
||||
"new_version": new_version,
|
||||
"version_text": version_text,
|
||||
@@ -423,17 +430,17 @@ jobs:
|
||||
"updated_manifests": updated_manifests,
|
||||
"would_update_files": would_update_files,
|
||||
"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] Mode:", report["mode"])
|
||||
print("[INFO] Would update files:", len(would_update_files))
|
||||
print("[INFO] Would update manifests:", len(would_update_manifests))
|
||||
print("[INFO] Updated files:", len(updated_files))
|
||||
print("[INFO] Updated manifests:", len(updated_manifests))
|
||||
PY
|
||||
print("[INFO] Report written to:", report_path)
|
||||
print("[INFO] Mode:", report["mode"])
|
||||
print("[INFO] Would update files:", len(would_update_files))
|
||||
print("[INFO] Would update manifests:", len(would_update_manifests))
|
||||
print("[INFO] Updated files:", len(updated_files))
|
||||
print("[INFO] Updated manifests:", len(updated_manifests))
|
||||
PY
|
||||
|
||||
- name: Commit changes
|
||||
if: ${{ env.REPORT_ONLY != 'true' }}
|
||||
|
||||
Reference in New Issue
Block a user