-
Notifications
You must be signed in to change notification settings - Fork 154
Expand file tree
/
Copy pathmake_release.py
More file actions
34 lines (25 loc) · 873 Bytes
/
Copy pathmake_release.py
File metadata and controls
34 lines (25 loc) · 873 Bytes
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
#!/usr/bin/env python3
"""This script is part of the GitHub CI make-release pipeline
It reads the version number from climada*/_version.py and then uses the `gh` cli
to create the new release.
"""
import glob
import re
import subprocess
def get_version() -> str:
"""Return the current version number, based on the _version.py file."""
[version_file] = glob.glob("climada*/_version.py")
with open(version_file, "r", encoding="UTF-8") as vfp:
content = vfp.read()
regex = r"^__version__\s*=\s*[\'\"](.*)[\'\"]\s*$"
mtch = re.match(regex, content)
return mtch.group(1)
def make_release():
"""run `gh release create vX.Y.Z"""
version_number = get_version()
subprocess.run(
["gh", "release", "create", "--generate-notes", f"v{version_number}"],
check=True,
)
if __name__ == "__main__":
make_release()