Skip to content

Commit

Permalink
Correct application to docs/conf.py; don't apply to pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
moble committed Sep 30, 2024
1 parent 9d4d6a5 commit 5bac788
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/scripts/update_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,24 @@
def update(version):
if not version:
raise ValueError("Can't replace version with empty string")
files = ("pyproject.toml", "setup.py", "src/quaternion/__init__.py")
short_version = ".".join(version.split(".")[:2])

files = ("setup.py", "src/quaternion/__init__.py")
pattern = re.compile('^(__version__|version) *= *".*?"')
replacement = r'\1 = "' + version + '"'
with fileinput.input(files=files, inplace=True) as f:
for line in f:
print(pattern.sub(replacement, line), end="")

files = ("docs/conf.py")
pattern = re.compile('^release *= *".*?"')
short_pattern = re.compile('^version *= *".*?"')
replacement = r'release = "' + version + '"'
short_replacement = r'version = "' + short_version + '"'
with fileinput.input(files=files, inplace=True) as f:
for line in f:
print(short_pattern.sub(short_replacement, pattern.sub(replacement, line)), end="")


version = os.environ["new_version"]

Expand Down

0 comments on commit 5bac788

Please sign in to comment.