-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_version.py
61 lines (43 loc) · 1.37 KB
/
update_version.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
55
56
57
58
59
60
61
import almapiwrapper
import re
import os
version = almapiwrapper.__version__
# docs/conf.py of documentation
with open('docs/conf.py') as f:
content = f.read()
content = re.sub(r"release = '.+'", f"release = '{version}'", content)
with open('docs/conf.py', 'w') as f:
f.write(content)
# pyproject.toml
with open('pyproject.toml') as f:
content = f.read()
content = re.sub(r'version = ".+"', f'version = "{version}"', content)
with open('pyproject.toml', 'w') as f:
f.write(content)
# README.rst
with open('README.rst') as f:
content = f.read()
content = re.sub(r'\* Version: \d+\.\d+\.\d+', f'* Version: {version}', content)
with open('README.rst', 'w') as f:
f.write(content)
# index.rst
with open('docs/index.rst') as f:
content = f.read()
content = re.sub(r'\* Version: \d+\.\d+\.\d+', f'* Version: {version}', content)
with open('docs/index.rst', 'w') as f:
f.write(content)
# Build the new doc
os.system(f'{os.getcwd()}/docs/make.bat html')
os.system(f'{os.getcwd()}/docs/make.bat html')
# Delete all files of dist folder
files = os.listdir('dist')
for f in files:
os.remove(f'dist/{f}')
# Build the new package
os.system('python -m build')
# Commit the new version
os.system('git add .')
os.system(f'git commit -m "Create version {version}"')
os.system(f'git push')
# Upload the package on pipy
os.system('python -m twine upload dist/*')