-
Notifications
You must be signed in to change notification settings - Fork 1
/
release_alpha.py
31 lines (24 loc) · 1017 Bytes
/
release_alpha.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
import re
import subprocess
# Run pip list and filter for "ovos-" packages
result = subprocess.run(['pip', 'list', '--format=freeze'], capture_output=True, text=True)
packages = result.stdout.splitlines()
alpha_constraints = []
# Regular expression to capture package name and version, with optional alpha tag
pattern = re.compile(r'^(ovos-[\w-]+)==(\d+)\.(\d+)\.(\d+)(a\d+)?$')
for package in packages:
match = pattern.match(package)
if match:
name, major, minor, patch, alpha = match.groups()
minver = f"{major}.{minor}.{patch}"
if alpha:
minver += f"{alpha}"
major = stable_major = int(major)
minor = stable_minor = int(minor)
patch = int(patch)
print(package)
alpha_constraints.append(f"{name}>={minver}")
# Write alpha constraints to respective files
with open('constraints-alpha.txt', 'w') as alpha_file:
alpha_file.write("\n".join(alpha_constraints))
print("Constraints files generated: constraints-alpha.txt")