Debian Codegraph @

dev/tools/release/release.py

raw
1 import datetime
2 import os
3 import sys
4
5 import brian2
6
7 basedir = os.path.abspath(
8 os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..")
9 )
10
11 # Ask for version number
12 print("Current version is: " + brian2.__version__)
13 version = input("Enter new Brian2 version number: ").strip()
14
15 # Run script to update codemeta.json
16 os.system(f"python {basedir}/.codemeta/create_codemeta.py {version}")
17
18 # Set version and release date in CITATION.cff
19 new_lines = []
20 with open(f"{basedir}/CITATION.cff") as f:
21 for line in f:
22 if line.startswith("version: "):
23 line = f"version: '{version}'\n"
24 if line.startswith("date-released: "):
25 line = f"date-released: '{datetime.date.today().isoformat()}'\n"
26 new_lines.append(line)
27 new_lines.append("") # Add empty line at the end
28 with open(f"{basedir}/CITATION.cff", "w") as f:
29 f.writelines(new_lines)
30
31 # commit
32 x = os.system(
33 f'git add {basedir}/codemeta.json && git add {basedir}/CITATION.cff && git commit -m "***** Release Brian2 {version} *****"'
34 )
35 if x:
36 print("Making commit failed with error code: ", x)
37 sys.exit(x)
38
39 # add tag
40 os.system(f'git tag -a -m "Release Brian2 {version}" {version}')
41
42 # print commands necessary for pushing
43 print("Review the last commit: ")
44 os.system("git show %s" % version)
45 print("")
46 print("To push, using the following command:")
47 print("git push --tags origin master")