Skip to content

Commit

Permalink
Add python script to update values for release
Browse files Browse the repository at this point in the history
  • Loading branch information
SSoelvsten committed Nov 30, 2023
1 parent eec588d commit f15f16a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ docs:

@cd build/ && $(MAKE) adiar_docs

# ============================================================================ #
# RELEASE
# ============================================================================ #
release:
python release.py

# ============================================================================ #
# PLAYGROUND
# ============================================================================ #
Expand Down
45 changes: 45 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# ---------------------------------------------------------------------------- #
# UPDATING FILES FOR RELEASES #
# ---------------------------------------------------------------------------- #
from datetime import datetime
import re

version = input("Version String: ").lower()
today = datetime.today().strftime('%Y-%m-%d')

yes_choices = ['yes', 'y']
no_choices = ['no', 'n']

# ---------------------------------------------------------------------------- #
# CITATION.cff #
# ---------------------------------------------------------------------------- #
file_name = "CITATION.cff"

if input(f"Update {file_name}? (yes/No): ").lower() in yes_choices:
content = ""

with open(file_name, 'r') as in_file:
content = in_file.read()

with open(file_name, 'w') as out_file:
content = re.sub(r"\ndate: .*\n", f"\ndate: {today}\n", content)
content = re.sub(r"\nversion: .*\n", f"\nversion: {version}\n", content)

out_file.write(content)

# ---------------------------------------------------------------------------- #
# CMakeLists.txt #
# ---------------------------------------------------------------------------- #
file_name = "CMakeLists.txt"

if input(f"Update {file_name}? (yes/No): ").lower() in yes_choices:
content = ""

with open(file_name, 'r') as in_file:
content = in_file.read()

with open(file_name, 'w') as out_file:
content = re.sub(r" VERSION .+\n", f" VERSION {version}\n", content)

out_file.write(content)

0 comments on commit f15f16a

Please sign in to comment.