-
Notifications
You must be signed in to change notification settings - Fork 32
/
tag_versions.py
executable file
·54 lines (38 loc) · 1.58 KB
/
tag_versions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
if sys.hexversion < 0x3040000:
print('Python >= 3.4 required')
sys.exit(1)
import os
import subprocess
import importlib.util
import importlib.machinery
generators_dir = os.path.dirname(os.path.realpath(__file__))
def create_generators_module():
if sys.hexversion < 0x3050000:
generators_module = importlib.machinery.SourceFileLoader('generators', os.path.join(generators_dir, '__init__.py')).load_module()
else:
generators_spec = importlib.util.spec_from_file_location('generators', os.path.join(generators_dir, '__init__.py'))
generators_module = importlib.util.module_from_spec(generators_spec)
generators_spec.loader.exec_module(generators_module)
sys.modules['generators'] = generators_module
if 'generators' not in sys.modules:
create_generators_module()
from generators import common
def main():
bindings = []
for binding in sorted(os.listdir(generators_dir)):
if not os.path.isdir(binding) or os.path.exists(os.path.join(generators_dir, binding, 'skip_tag_versions')):
continue
if binding not in ['.git', '.m2', '.vscode', '__pycache__', 'configs', 'docker']:
bindings.append(binding)
for binding in bindings:
path = os.path.join(generators_dir, binding)
version = common.get_changelog_version(path)
tag = '{0}-{1}.{2}.{3}'.format(binding, *version)
args = ['git', 'tag', tag]
print('=== Tagging {0} ======'.format(tag))
subprocess.call(args)
if __name__ == '__main__':
main()