Update version_branch.yml
This commit is contained in:
96
.github/workflows/version_branch.yml
vendored
96
.github/workflows/version_branch.yml
vendored
@@ -353,7 +353,6 @@ jobs:
|
|||||||
echo "[ERROR] No VERSION: (NN.NN.NN) or <version> tags found outside .github" >&2
|
echo "[ERROR] No VERSION: (NN.NN.NN) or <version> tags found outside .github" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Bump versions and update manifest dates (targeted, excluding .github)
|
- name: Bump versions and update manifest dates (targeted, excluding .github)
|
||||||
run: |
|
run: |
|
||||||
source "$CI_HELPERS"
|
source "$CI_HELPERS"
|
||||||
@@ -374,28 +373,74 @@ jobs:
|
|||||||
stamp = datetime.now(timezone.utc).strftime('%Y-%m-%d')
|
stamp = datetime.now(timezone.utc).strftime('%Y-%m-%d')
|
||||||
root = Path('.').resolve()
|
root = Path('.').resolve()
|
||||||
|
|
||||||
header_re = re.compile(r'(?im)(VERSION[ ]*:[ ]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})')
|
header_re = re.compile(r'(?im)(VERSION[ ]*:[ ]*)([0-9]{2}[.][0-9]{2}[.][0-9]{2})')
|
||||||
|
|
||||||
manifest_marker_re = re.compile(r'(?is)<extension\b')
|
manifest_marker_re = re.compile(r'(?is)<extension')
|
||||||
# Joomla update server feeds are release artifacts and must not exist on version branches
|
xml_version_re = re.compile(r'(?is)(<version[ ]*>)([^<]*?)(</version[ ]*>)')
|
||||||
# update.xml / updates.xml are intentionally excluded here
|
xml_date_res = [
|
||||||
if p.suffix.lower() == '.xml':
|
re.compile(r'(?is)(<creationDate[ ]*>)([^<]*?)(</creationDate[ ]*>)'),
|
||||||
if manifest_marker_re.search(text):
|
re.compile(r'(?is)(<date[ ]*>)([^<]*?)(</date[ ]*>)'),
|
||||||
text2, n2 = xml_version_re.subn(lambda m: m.group(1) + new_version + m.group(3), text)
|
re.compile(r'(?is)(<releaseDate[ ]*>)([^<]*?)(</releaseDate[ ]*>)'),
|
||||||
text = text2
|
]
|
||||||
if n2:
|
|
||||||
counters['xml_version_replacements'] += n2
|
|
||||||
|
|
||||||
for rx in xml_date_res:
|
skip_ext = {
|
||||||
text3, n3 = rx.subn(lambda m: m.group(1) + stamp + m.group(3), text)
|
'.json', '.png', '.jpg', '.jpeg', '.gif', '.svg', '.ico', '.pdf',
|
||||||
text = text3
|
'.zip', '.7z', '.tar', '.gz', '.woff', '.woff2', '.ttf', '.otf',
|
||||||
if n3:
|
'.mp3', '.mp4'
|
||||||
counters['xml_date_replacements'] += n3
|
}
|
||||||
|
skip_dirs = {'.git', '.github', 'node_modules', 'vendor', '.venv', 'dist', 'build'}
|
||||||
|
|
||||||
if text != original:
|
counters = defaultdict(int)
|
||||||
updated_manifests.append(str(p))
|
updated = []
|
||||||
else:
|
updated_manifests = []
|
||||||
counters['xml_skipped_non_manifest'] += 1s['xml_skipped_non_manifest'] += 1
|
|
||||||
|
def should_skip(p: Path) -> bool:
|
||||||
|
if p.suffix.lower() in skip_ext:
|
||||||
|
counters['skipped_by_ext'] += 1
|
||||||
|
return True
|
||||||
|
parts = {x.lower() for x in p.parts}
|
||||||
|
if any(d in parts for d in skip_dirs):
|
||||||
|
counters['skipped_by_dir'] += 1
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
for p in root.rglob('*'):
|
||||||
|
if not p.is_file():
|
||||||
|
continue
|
||||||
|
if should_skip(p):
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Release only artifacts: never version bumped on version branch creation
|
||||||
|
if p.parent == root and p.name.lower() in {'update.xml', 'updates.xml'}:
|
||||||
|
counters['skipped_release_artifacts'] += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
try:
|
||||||
|
text = p.read_text(encoding='utf-8', errors='replace')
|
||||||
|
except Exception:
|
||||||
|
counters['skipped_read_error'] += 1
|
||||||
|
continue
|
||||||
|
|
||||||
|
original = text
|
||||||
|
|
||||||
|
text, n1 = header_re.subn(lambda m: m.group(1) + new_version, text)
|
||||||
|
if n1:
|
||||||
|
counters['header_replacements'] += n1
|
||||||
|
|
||||||
|
if p.suffix.lower() == '.xml' and manifest_marker_re.search(text):
|
||||||
|
text2, n2 = xml_version_re.subn(lambda m: m.group(1) + new_version + m.group(3), text)
|
||||||
|
text = text2
|
||||||
|
if n2:
|
||||||
|
counters['xml_version_replacements'] += n2
|
||||||
|
|
||||||
|
for rx in xml_date_res:
|
||||||
|
text3, n3 = rx.subn(lambda m: m.group(1) + stamp + m.group(3), text)
|
||||||
|
text = text3
|
||||||
|
if n3:
|
||||||
|
counters['xml_date_replacements'] += n3
|
||||||
|
|
||||||
|
if text != original:
|
||||||
|
updated_manifests.append(str(p))
|
||||||
|
|
||||||
if text != original:
|
if text != original:
|
||||||
p.write_text(text, encoding='utf-8')
|
p.write_text(text, encoding='utf-8')
|
||||||
@@ -431,21 +476,10 @@ jobs:
|
|||||||
|
|
||||||
if [[ -f "update.xml" ]]; then
|
if [[ -f "update.xml" ]]; then
|
||||||
echo "[INFO] update.xml present at repo root. Clearing contents because it is release generated only."
|
echo "[INFO] update.xml present at repo root. Clearing contents because it is release generated only."
|
||||||
|
|
||||||
# Truncate file but keep it tracked for release workflows
|
|
||||||
: > "update.xml"
|
: > "update.xml"
|
||||||
echo "[INFO] update.xml contents cleared"
|
echo "[INFO] update.xml contents cleared"
|
||||||
else
|
else
|
||||||
echo "[INFO] update.xml not present. No action taken."
|
echo "[INFO] update.xml not present. No action taken."
|
||||||
files --error-unmatch "update.xml" >/dev/null 2>&1; then
|
|
||||||
git rm -f "update.xml"
|
|
||||||
echo "[INFO] update.xml removed from index"
|
|
||||||
else
|
|
||||||
rm -f "update.xml"
|
|
||||||
echo "[INFO] update.xml removed from working tree"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "[INFO] update.xml not present. No action taken."
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Post bump audit (updates.xml date only)
|
- name: Post bump audit (updates.xml date only)
|
||||||
|
|||||||
Reference in New Issue
Block a user