From 418d86a16ff163657baf73b7215eb9fc7425fb7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Tue, 31 Aug 2021 12:21:02 +0200 Subject: [PATCH] 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: --- meson.build | 1 + meson/check-version.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100755 meson/check-version.py diff --git a/meson.build b/meson.build index 5c891a504..b9c7ef750 100644 --- a/meson.build +++ b/meson.build @@ -298,6 +298,7 @@ endif meson.add_install_script('meson/postinstall.py') meson.add_dist_script('meson/generate-manpages.py') meson.add_dist_script('meson/generate-stylesheets.py') +meson.add_dist_script('meson/check-version.py', meson.project_version(), 'NEWS') summary_options = { 'networkmanager': get_option('networkmanager'), diff --git a/meson/check-version.py b/meson/check-version.py new file mode 100755 index 000000000..81750c990 --- /dev/null +++ b/meson/check-version.py @@ -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)