Skip to content

Commit

Permalink
* update
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhughes-usgs committed Jun 17, 2024
1 parent b454063 commit 7c4bc64
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
jobs:

pymake-os-compiler:
name: pymake CI on different OSs with gcc and intel-classic
name: pymake compilers
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -114,7 +114,7 @@ jobs:
file: ./autotest/coverage.xml

pymake-schedule:
name: pymake scheduled CI different OSs with gcc and intel-classic
name: pymake scheduled
if: ${{ github.event_name == 'schedule' }}
runs-on: ${{ matrix.os }}
strategy:
Expand Down
12 changes: 0 additions & 12 deletions pymake/config.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
# mfpymake version file automatically created using
# update_version.py on June 17, 2024 09:42:26

# mfpymake version file automatically created using
# update_version.py on June 17, 2024 09:33:29

# mfpymake version file automatically created using
# update_version.py on June 17, 2024 09:31:39

# mfpymake version file automatically created using
# update_version.py on June 16, 2024 18:36:44

__author__ = "Joseph D. Hughes"
__date__ = "June 17, 2024"
__version__ = "1.2.10.dev0"
Expand Down
72 changes: 51 additions & 21 deletions scripts/update_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,32 @@ def split_nonnumeric(s):
_current_version = Version(_version_txt_path.read_text().strip())


def update_version_txt(version: Version):
with open(_version_txt_path, "w") as f:
def update_version_txt(version: Version) -> None:
"""Update version number in version.txt
Parameters
----------
version : Version
version number
"""
with open(_version_txt_path, "w", encoding="utf8") as f:
f.write(str(version))
print(f"Updated {_version_txt_path} to version {version}")


def update_version_py(timestamp: datetime, version: Version):
def update_version_py(timestamp: datetime, version: Version) -> None:
"""Update version number in config.py
Parameters
----------
timestamp : datetime
current datetime
version : Version
version number
"""
lines = file_paths["config.py"].read_text().rstrip().split("\n")

with open(_version_py_path, "w") as f:
f.write(
f"# {_project_name} version file automatically created using\n"
f"# {Path(__file__).name} on {timestamp:%B %d, %Y %H:%M:%S}\n\n"
)
with open(_version_py_path, "w", encoding="utf8") as f:
for line in lines:
if "__date__" in line:
line = f'__date__ = "{timestamp:%B %d, %Y}"'
Expand All @@ -55,18 +67,22 @@ def update_version_py(timestamp: datetime, version: Version):
print(f"Updated {_version_py_path} to version {version}")


def update_readme_markdown(
timestamp: datetime,
version: Version,
):
def update_readme_markdown(version: Version) -> None:
"""Update README.md
Parameters
----------
version : Version
version number
"""
fpth = file_paths["README.md"]

# read README.md into memory
lines = fpth.read_text().rstrip().split("\n")

# rewrite README.md
terminate = False
with open(fpth, "w") as f:
with open(fpth, "w", encoding="utf8") as f:
for line in lines:
if "### Version " in line:
line = f"### Version {version}"
Expand All @@ -77,18 +93,22 @@ def update_readme_markdown(
print(f"Updated {fpth} to version {version}")


def update_codejson(
timestamp: datetime,
version: Version,
):
def update_codejson(version: Version) -> None:
"""Update code.json
Parameters
----------
version : Version
version number
"""
# define json filename
json_fname = file_paths["code.json"]

# load and modify json file
data = json.loads(json_fname.read_text())

# rewrite the json file
with open(json_fname, "w") as f:
with open(json_fname, "w", encoding="utf8") as f:
json.dump(data, f, indent=4)
f.write("\n")

Expand All @@ -98,7 +118,17 @@ def update_codejson(
def update_version(
timestamp: datetime = datetime.now(),
version: Version = None,
):
) -> None:
"""Main function for updating all of the files containing
version information
Parameters
----------
timestamp : datetime, optional
datetime object, by default datetime.now()
version : Version, optional
version number, by default None
"""
lock_path = Path(_version_txt_path.name + ".lock")
try:
lock = FileLock(lock_path)
Expand All @@ -112,8 +142,8 @@ def update_version(
with lock:
update_version_txt(version)
update_version_py(timestamp, version)
update_readme_markdown(timestamp, version)
update_codejson(timestamp, version)
update_readme_markdown(version)
update_codejson(version)
finally:
try:
lock_path.unlink()
Expand Down

0 comments on commit 7c4bc64

Please sign in to comment.