Files
wekan/releases/dependency-versions.py
T
Lauri Ojansivu 11f97d016e Windows builds: the release scripts read and write text as UTF-8.
All three Windows bundle builds of v12.47 stopped at the risk audit:
"Automated risk indicators found: server/lib/localizeAvatar.js: new URL
origin http://127.0.0.1". The file had not changed. risk-audit.py read
its baseline with a bare read_text(), which on a Windows runner decodes
cp1252, so the baseline's "http://127.0.0.1/…" (a comment in that file)
became "http://127.0.0.1/…" and no longer matched the source. With a
non-UTF-8 default on Linux (LC_ALL=C, -X utf8=0) the old script misread
the baseline the same way and counted all 16688 files as changed; the
fixed one reads it as the build does.

Every text read and write in releases/*.py now names UTF-8: the risk
audit, the telemetry check, remote-release.py (which also reads and
rewrites CHANGELOG.md, with its ®), the dependency, UCS, Nextcloud, Bun,
Mac and Snap scripts, and the GITHUB_ENV/GITHUB_OUTPUT writes.
tests/releaseScriptsUtf8.test.cjs fails on any read_text(), write_text()
or text-mode open() in releases/ without an encoding, multi-line calls
included; tests/bun-release.py follows the checksum write's new
argument. Every Python and node test of these scripts passes.

Thanks to xet7 !
2026-10-15 16:37:18 +03:00

58 lines
2.3 KiB
Python

#!/usr/bin/env python3
"""Resolve stable runtime releases from official metadata, without modifying files."""
import argparse
import json
import re
import subprocess
import sys
from pathlib import Path
def stable(value, major):
return bool(re.fullmatch(str(major) + r'\.\d+\.\d+', value))
def select(node, mongo, npm):
nodes = [r['version'][1:] for r in node
if stable(r.get('version', '')[1:], 26)
and {'linux-x64', 'linux-arm64'} <= set(r.get('files', []))]
mongos = []
for release in mongo['versions']:
version = release.get('version', '')
if not stable(version, 7) or not version.startswith("7.0."):
continue
urls = {d.get('archive', {}).get('url') for d in release.get('downloads', [])}
if all('https://fastdl.mongodb.org/linux/mongodb-linux-' + arch +
'-ubuntu2204-' + version + '.tgz' in urls
for arch in ('x86_64', 'aarch64')):
mongos.append(version)
npm_version = npm.get('version', '')
if not nodes or not mongos or not stable(npm_version, 12):
raise ValueError('No stable Node 26 / MongoDB 7.0 architecture pair or supported npm 12 release in metadata')
key = lambda value: tuple(map(int, value.split('.')))
return max(nodes, key=key), max(mongos, key=key), npm_version
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('--metadata-dir', type=Path, help='offline metadata fixtures')
args = parser.parse_args()
data = []
for name, url in [('node', 'https://nodejs.org/dist/index.json'),
('mongo', 'https://downloads.mongodb.org/full.json'),
('npm', 'https://registry.npmjs.org/npm/latest')]:
if args.metadata_dir:
raw = (args.metadata_dir / (name + '.json')).read_text(encoding='utf-8')
else:
raw = subprocess.check_output(['curl', '-fsSL', '--retry', '2',
'--connect-timeout', '15', '--max-time', '60', url], text=True)
data.append(json.loads(raw))
print(' '.join(select(*data)))
if __name__ == '__main__':
try:
main()
except (ValueError, KeyError, TypeError, OSError, subprocess.CalledProcessError) as error:
sys.exit('Error resolving runtime versions: ' + str(error))