Update version_branch.yml

This commit is contained in:
2025-12-18 19:04:34 -06:00
parent 0a21e29d6c
commit 5d63ecb8b7

View File

@@ -1,4 +1,3 @@
---
#
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
#
@@ -462,58 +461,53 @@ jobs:
raise SystemExit(0)
PY
- name: Post bump audit (version consistency)
- name: Post bump audit (updates.xml date only)
run: |
source "$CI_HELPERS"
moko_init "Post bump audit"
moko_init "Post bump audit (updates.xml date only)"
python3 - <<'PY'
import os
import json
import re
from pathlib import Path
new_version = (os.environ.get('NEW_VERSION') or '').strip()
if not new_version:
raise SystemExit('[FATAL] NEW_VERSION env var missing')
report_path = Path('.github/version-bump-report.json')
if not report_path.exists():
print('[INFO] No bump report found. Skipping updates.xml audit.')
raise SystemExit(0)
root = Path('.').resolve()
skip_dirs = {'.git', '.github', 'node_modules', 'vendor', '.venv', 'dist', 'build'}
report = json.loads(report_path.read_text(encoding='utf-8', errors='replace'))
stamp = (report.get('stamp_utc') or '').strip()
if not stamp:
print('[INFO] No stamp_utc in bump report. Skipping updates.xml audit.')
raise SystemExit(0)
header_re = re.compile(r'(?im)VERSION[ ]*:[ ]*([0-9]{2}[.][0-9]{2}[.][0-9]{2})')
xml_version_re = re.compile(r'(?is)<version[ ]*>([^<]*?)</version[ ]*>')
p = Path('updates.xml')
if not p.exists():
print('[INFO] updates.xml not present. Skipping updates.xml date audit.')
raise SystemExit(0)
text = p.read_text(encoding='utf-8', errors='replace')
tags = ['creationDate', 'date', 'releaseDate']
mismatches = []
for p in root.rglob('*'):
if not p.is_file():
for t in tags:
rx = re.compile(r'(?is)<' + re.escape(t) + r'\\s*>([^<]*?)</' + re.escape(t) + r'\\s*>')
m = rx.search(text)
if not m:
continue
parts = {x.lower() for x in p.parts}
if any(d in parts for d in skip_dirs):
continue
if p.suffix.lower() in {'.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.pdf', '.zip', '.7z', '.tar', '.gz', '.woff', '.woff2', '.ttf', '.otf', '.mp3', '.mp4', '.json'}:
continue
try:
text = p.read_text(encoding='utf-8', errors='replace')
except Exception:
continue
for m in header_re.finditer(text):
if m.group(1).strip() != new_version:
mismatches.append(str(p) + ' :: VERSION: ' + m.group(1).strip())
if p.suffix.lower() == '.xml' and '<extension' in text.lower():
for m in xml_version_re.finditer(text):
if m.group(1).strip() != new_version:
mismatches.append(str(p) + ' :: <version> ' + m.group(1).strip())
current = (m.group(1) or '').strip()
if current != stamp:
mismatches.append('<' + t + '> ' + current + ' != ' + stamp)
if mismatches:
print('[ERROR] Version consistency audit failed. Mismatches found:')
for x in mismatches[:200]:
print('[ERROR] updates.xml date audit failed. Mismatches found:')
for x in mismatches:
print(' ' + x)
raise SystemExit(2)
print('[INFO] Version consistency audit passed')
print('[INFO] updates.xml date audit passed')
PY
- name: Change scope guard (block .github edits)