[gnome-shell-extensions] build: Check NEWS for version



commit 769ad859e628554c139c175d1780cb4a6932b4ff
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Aug 31 10:27:05 2021 +0200

    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.
    
    (The script has been copied from Polari, thus the metainfo support)
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/186>

 meson.build            |  3 +++
 meson/check-version.py | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
---
diff --git a/meson.build b/meson.build
index 6573b7d..1b145b8 100644
--- a/meson.build
+++ b/meson.build
@@ -89,3 +89,6 @@ subdir('extensions')
 subdir('po')
 
 meson.add_dist_script('meson/generate-stylesheets.py')
+meson.add_dist_script('meson/check-version.py',
+  meson.project_version(),
+  'NEWS')
diff --git a/meson/check-version.py b/meson/check-version.py
new file mode 100755
index 0000000..81750c9
--- /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)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]