build: Check NEWS for version

I don't think this ever happened to me, but it can't hurt enforcing
that every release has a corresponding NEWS entry.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1968>
This commit is contained in:
Florian Müllner 2021-08-31 12:21:02 +02:00
parent 4d4f3d25d8
commit 418d86a16f
2 changed files with 33 additions and 0 deletions

View File

@ -298,6 +298,7 @@ endif
meson.add_install_script('meson/postinstall.py') meson.add_install_script('meson/postinstall.py')
meson.add_dist_script('meson/generate-manpages.py') meson.add_dist_script('meson/generate-manpages.py')
meson.add_dist_script('meson/generate-stylesheets.py') meson.add_dist_script('meson/generate-stylesheets.py')
meson.add_dist_script('meson/check-version.py', meson.project_version(), 'NEWS')
summary_options = { summary_options = {
'networkmanager': get_option('networkmanager'), 'networkmanager': get_option('networkmanager'),

32
meson/check-version.py Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env python3
import os, sys
from pathlib import Path
import argparse, subprocess
def check_version(version, file, type='news'):
if type == 'news':
line = file.open().readline()
ok = line.startswith(version)
print("{}: {}".format(file, "OK" if ok else "FAILED"))
if not ok:
raise Exception("{} does not start with {}".format(file, version))
elif type == 'metainfo':
subprocess.run(['appstream-util', 'validate-version', file, version],
check=True)
else:
raise Exception('Not implemented')
parser = argparse.ArgumentParser(description='Check release version information.')
parser.add_argument('--type', choices=['metainfo','news'], default='news')
parser.add_argument('version', help='the version to check for')
parser.add_argument('files', nargs='+', help='files to check')
args = parser.parse_args()
distroot = os.environ.get('MESON_DIST_ROOT', './')
try:
for file in args.files:
check_version(args.version, Path(distroot, file), args.type)
except:
sys.exit(1)