Skip to content

Commit 39be246

Browse files
authored
Version manager (#104)
* add version manager * update toml * no default version * add citation * config file * config file * config file * config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * fix config file * remove check flags * remove check flags * update cfg file * update cfg file * update cfg file * update cfg file * update cfg file * simplify CI * remove dates and add script for version * fix script * prepare script for version bump * prepare script for version bump * update script * finalize script * finalize script * add bump2version to setup.py
1 parent 95a3413 commit 39be246

File tree

11 files changed

+74
-665
lines changed

11 files changed

+74
-665
lines changed

.bumpversion.cfg

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
[bumpversion]
2+
current_version = 2.1.0.dev0
3+
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<dev>dev0))?
4+
serialize =
5+
{major}.{minor}.{patch}.{dev}
6+
{major}.{minor}.{patch}
7+
8+
[bumpversion:file:setup.py]
9+
search = package_version = "{current_version}"
10+
replace = package_version = "{new_version}"
11+
12+
[bumpversion:file:CITATION.cff]
13+
search = version: {current_version}
14+
replace = version: {new_version}
15+
16+
[bumpversion:file:README.md]
17+
search = {current_version}
18+
replace = {new_version}
19+
20+
[bumpversion:file:src/simulated_bifurcation/__init__.py]
21+
search = __version__ = "{current_version}"
22+
replace = __version__ = "{new_version}"

.github/bump_for_release.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import argparse
2+
import datetime
3+
import os
4+
import re
5+
6+
7+
def check_release_month(line: str, current_date: datetime.date):
8+
current_month = current_date.strftime("%B").lower()[:3]
9+
month_match = re.search("month = (?P<month>[a-z]{3})", line)
10+
if month_match is not None:
11+
print(month_match["month"])
12+
if month_match is not None and month_match["month"] != current_month:
13+
raise ValueError(
14+
f"Release month in README.md ({month_match['month']}) is not consistent with current month ({current_month}). Please update it."
15+
)
16+
17+
18+
def check_release_year(line: str, current_date: datetime.date):
19+
current_year = str(current_date.year)
20+
year_match = re.search("year = {(?P<year>\d{4})}", line)
21+
if year_match is not None and year_match["year"] != current_year:
22+
raise ValueError(
23+
f"Release year in README.md ({year_match['year']}) is not consistent with current year ({current_year}). Please update it."
24+
)
25+
26+
27+
def check_release_date():
28+
current_date = datetime.date.today()
29+
with open("README.md", "r") as readme:
30+
lines = readme.readlines()
31+
for line in lines:
32+
check_release_month(line, current_date)
33+
check_release_year(line, current_date)
34+
35+
36+
if __name__ == "__main__":
37+
parser = argparse.ArgumentParser()
38+
parser.add_argument(
39+
"version", metavar="N", type=int, nargs=3, help="major / minor / patch"
40+
)
41+
42+
args = parser.parse_args()
43+
major, minor, patch = args.version
44+
45+
check_release_date()
46+
47+
new_branch = f"prepare-release-{major}.{minor}.{patch}"
48+
os.system(f"git checkout -b {new_branch}")
49+
os.system(f"bump2version --new-version {major}.{minor}.{patch} --commit .")
50+
os.system(f"bump2version --new-version {major}.{minor + 1}.0.dev0 --commit .")
51+
os.system(f"git push --set-upstream origin {new_branch}")

.github/scripts/metadata_checker/__main__.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/scripts/metadata_checker/config.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/scripts/metadata_checker/errors.py

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)