Update version_branch.yml
This commit is contained in:
64
.github/workflows/version_branch.yml
vendored
64
.github/workflows/version_branch.yml
vendored
@@ -1,4 +1,3 @@
|
|||||||
---
|
|
||||||
#
|
#
|
||||||
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
|
# Copyright (C) 2025 Moko Consulting <hello@mokoconsulting.tech>
|
||||||
#
|
#
|
||||||
@@ -462,58 +461,53 @@ jobs:
|
|||||||
raise SystemExit(0)
|
raise SystemExit(0)
|
||||||
PY
|
PY
|
||||||
|
|
||||||
- name: Post bump audit (version consistency)
|
- name: Post bump audit (updates.xml date only)
|
||||||
run: |
|
run: |
|
||||||
source "$CI_HELPERS"
|
source "$CI_HELPERS"
|
||||||
moko_init "Post bump audit"
|
moko_init "Post bump audit (updates.xml date only)"
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
import os
|
import json
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
new_version = (os.environ.get('NEW_VERSION') or '').strip()
|
report_path = Path('.github/version-bump-report.json')
|
||||||
if not new_version:
|
if not report_path.exists():
|
||||||
raise SystemExit('[FATAL] NEW_VERSION env var missing')
|
print('[INFO] No bump report found. Skipping updates.xml audit.')
|
||||||
|
raise SystemExit(0)
|
||||||
|
|
||||||
root = Path('.').resolve()
|
report = json.loads(report_path.read_text(encoding='utf-8', errors='replace'))
|
||||||
skip_dirs = {'.git', '.github', 'node_modules', 'vendor', '.venv', 'dist', 'build'}
|
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})')
|
p = Path('updates.xml')
|
||||||
xml_version_re = re.compile(r'(?is)<version[ ]*>([^<]*?)</version[ ]*>')
|
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 = []
|
mismatches = []
|
||||||
|
|
||||||
for p in root.rglob('*'):
|
for t in tags:
|
||||||
if not p.is_file():
|
rx = re.compile(r'(?is)<' + re.escape(t) + r'\\s*>([^<]*?)</' + re.escape(t) + r'\\s*>')
|
||||||
|
m = rx.search(text)
|
||||||
|
if not m:
|
||||||
continue
|
continue
|
||||||
parts = {x.lower() for x in p.parts}
|
current = (m.group(1) or '').strip()
|
||||||
if any(d in parts for d in skip_dirs):
|
if current != stamp:
|
||||||
continue
|
mismatches.append('<' + t + '> ' + current + ' != ' + stamp)
|
||||||
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())
|
|
||||||
|
|
||||||
if mismatches:
|
if mismatches:
|
||||||
print('[ERROR] Version consistency audit failed. Mismatches found:')
|
print('[ERROR] updates.xml date audit failed. Mismatches found:')
|
||||||
for x in mismatches[:200]:
|
for x in mismatches:
|
||||||
print(' ' + x)
|
print(' ' + x)
|
||||||
raise SystemExit(2)
|
raise SystemExit(2)
|
||||||
|
|
||||||
print('[INFO] Version consistency audit passed')
|
print('[INFO] updates.xml date audit passed')
|
||||||
PY
|
PY
|
||||||
|
|
||||||
- name: Change scope guard (block .github edits)
|
- name: Change scope guard (block .github edits)
|
||||||
|
|||||||
Reference in New Issue
Block a user