Debian Codegraph @

ci/check_project_version.py

raw
1 # This script checks that the project's version is the same in a few files where it must appear.
2
3 import sys
4 import toml
5
6 from utils import get_project_version_str
7
8 def get_cargo_toml_version():
9 doc = toml.load('Cargo.toml')
10 return doc['workspace']['package']['version']
11
12 def get_doc_version():
13 doc = toml.load('doc/librsvg.toml')
14 return doc['library']['version']
15
16 def main():
17 versions = [
18 ['meson.build', get_project_version_str()],
19 ['Cargo.toml', get_cargo_toml_version()],
20 ['doc/librsvg.toml', get_doc_version()],
21 ]
22
23 all_the_same = True
24
25 for filename, version in versions[1:]:
26 if version != versions[0][1]:
27 all_the_same = False
28
29 if not all_the_same:
30 print('Version numbers do not match, please fix them!\n', file=sys.stderr)
31 for filename, version in versions:
32 print(f'{filename}: {version}', file=sys.stderr)
33
34 sys.exit(1)
35
36 print('Versions number match. All good!', file=sys.stderr)
37
38 if __name__ == "__main__":
39 main()