Skip to content

Commit

Permalink
Remove README version check and update
Browse files Browse the repository at this point in the history
  • Loading branch information
freddyheppell committed Jan 12, 2024
1 parent ed2b942 commit e184954
Showing 1 changed file with 1 addition and 36 deletions.
37 changes: 1 addition & 36 deletions version.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
DOCS_PACKAGE_JSON_FILE_PATH = "docs/package.json"
CITATION_FILE_PATH = "CITATION.cff"
MASTER_VERSION_FILE = "VERSION"
README_FILE_PATH = "README.md"
README_VERSION_REGEX = r"\(Version ([^)]*)\)"

def check():
"""
Expand All @@ -30,13 +28,10 @@ def check():
citation_version = citation_file['version']
print(f"{CITATION_FILE_PATH} version is {citation_version}")

readme_version = get_readme_version(README_FILE_PATH)
print(f"{README_FILE_PATH} version is {readme_version}")

master_version = get_master_version()
print(f"VERSION file version is {master_version}")

if js_version != master_version or docs_js_version != master_version or citation_version != master_version or readme_version != master_version:
if js_version != master_version or docs_js_version != master_version or citation_version != master_version:
print("One or more versions does not match")
sys.exit(1)
else:
Expand All @@ -49,21 +44,6 @@ def get_package_json_version(file_path: str) -> str:
js_version = package_json['version']
return js_version

def get_readme_version(file_path: str) -> str:
with open(file_path, 'r') as f:
readme_text = f.read()

match = re.search(README_VERSION_REGEX, readme_text)

if match is None:
print(f"No version found in {README_FILE_PATH}.")
return
elif len(match.groups()) > 1:
print(f"{len(match.groups())} matches found in {README_FILE_PATH}, expected 1.")
return
else:
return match.groups(1)[0]

def get_master_version():
with open(MASTER_VERSION_FILE, "r") as f:
master_version = f.readline().strip()
Expand All @@ -83,8 +63,6 @@ def update(master_version:str = None):

update_package_json_version(DOCS_PACKAGE_JSON_FILE_PATH, master_version)

update_readme_version(README_FILE_PATH, master_version)

with open(CITATION_FILE_PATH, "r") as f:
citation_file = yaml.safe_load(f)
print(f"Writing master version {master_version} to {CITATION_FILE_PATH}")
Expand All @@ -102,19 +80,6 @@ def update_package_json_version(file_path:str, version_no:str):
package_json['version'] = version_no
json.dump(package_json, f, indent=2)

def update_readme_version(file_path:str, version_no:str):
with open(file_path, 'r') as f:
readme_text = f.read()

readme_text = re.sub(
README_VERSION_REGEX,
f'(Version {version_no})',
readme_text
)

with open(file_path, 'w') as f:
f.write(readme_text)


if __name__ == "__main__":
if sys.argv[1] == 'check':
Expand Down

0 comments on commit e184954

Please sign in to comment.