Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions infra/scripts/release/bump_file_versions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This script will bump the versions found in files (charts, pom.xml) during the Feast release process.

import re
import pathlib
import sys

Expand Down Expand Up @@ -45,7 +46,9 @@ def main() -> None:
with open(repo_root.joinpath(file_path), "r") as f:
file_contents = f.readlines()
for line in lines:
file_contents[int(line) - 1] = file_contents[int(line) - 1].replace(current_version, new_version)
# note we validate the version above already
current_parsed_version = _get_semantic_version(file_contents[int(line) - 1])
file_contents[int(line) - 1] = file_contents[int(line) - 1].replace(current_parsed_version, new_version)

with open(repo_root.joinpath(file_path), "w") as f:
f.write(''.join(file_contents))
Expand Down Expand Up @@ -73,11 +76,19 @@ def validate_files_to_bump(current_version, files_to_bump, repo_root):
with open(repo_root.joinpath(file_path), "r") as f:
file_contents = f.readlines()
for line in lines:
assert current_version in file_contents[int(line) - 1], (
new_version = _get_semantic_version(file_contents[int(line) - 1])
current_major_minor_version = '.'.join(current_version.split(".")[0:1])
assert current_version in new_version or current_major_minor_version in new_version, (
f"File `{file_path}` line `{line}` didn't contain version {current_version}. "
f"Contents: {file_contents[int(line) - 1]}"
)


def _get_semantic_version(input_string: str) -> str:
semver_pattern = r'\bv?(\d+\.\d+\.\d+)\b'
match = re.search(semver_pattern, input_string)
return match.group(1)


if __name__ == "__main__":
main()