From f15f16aab4b3dc12c45cdb6089d3a17f40049d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffan=20S=C3=B8lvsten?= Date: Thu, 30 Nov 2023 15:57:23 -0500 Subject: [PATCH] Add python script to update values for release --- makefile | 6 ++++++ release.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 release.py diff --git a/makefile b/makefile index d0de69fd3..38412faba 100644 --- a/makefile +++ b/makefile @@ -244,6 +244,12 @@ docs: @cd build/ && $(MAKE) adiar_docs +# ============================================================================ # +# RELEASE +# ============================================================================ # +release: + python release.py + # ============================================================================ # # PLAYGROUND # ============================================================================ # diff --git a/release.py b/release.py new file mode 100644 index 000000000..0dfae55a5 --- /dev/null +++ b/release.py @@ -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) +