Skip to content

CD always get latest version #395

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion utils/publish-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pushd $(dirname $0) > /dev/null

# Get the current version
git checkout main
current_version=$(git describe --tags --abbrev=0)

git_tags=$(git tag)
current_version=$(python3 ./update_semantic_version.py --version "${git_tags}" --type MINOR --parse_latest_version true)
current_version_without_v=$(echo ${current_version} | cut -f2 -dv)

echo "Current release version is ${current_version_without_v}"
Expand Down
38 changes: 38 additions & 0 deletions utils/update_semantic_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,46 @@ def main():
required=True, help="The version string to update")
argument_parser.add_argument("--type", metavar="<string containing PATCH, MINOR, or MAJOR>",
required=True, help="Which version number to bump")
argument_parser.add_argument("--parse_latest_version", metavar="<true>",
help="Takes '$(git tag)' and returns the highest version in the list", default="false")
parsed_commands = argument_parser.parse_args()

if (parsed_commands.parse_latest_version == "true"):
version_list = parsed_commands.version.split("\n")
highest = [0, 0, 0]

for i in range(0, len(version_list)):
i_version = version_list[i]
i_version = i_version.replace("v", "")

i_version_tuple = i_version.split(".")
if (len(i_version_tuple) != 3):
continue

i_version_tuple[0] = int(i_version_tuple[0])
i_version_tuple[1] = int(i_version_tuple[1])
i_version_tuple[2] = int(i_version_tuple[2])

if (highest == None):
highest = i_version_tuple
continue
else:
if (i_version_tuple[0] > highest[0]):
highest = i_version_tuple
continue
if (i_version_tuple[0] >= highest[0] and i_version_tuple[1] > highest[1]):
highest = i_version_tuple
continue
if (i_version_tuple[0] >= highest[0] and i_version_tuple[1] >= highest[1] and i_version_tuple[2] >= highest[2]):
highest = i_version_tuple
continue

if (highest[0] != 0 and highest[1] != 0 and highest[2] != 0):
print(f"v{highest[0]}.{highest[1]}.{highest[2]}")
sys.exit(0)
else:
sys.exit(-1)

version_tuple = parsed_commands.version.split(".")
if len(version_tuple) != 3:
print("0.0.0") # Error
Expand Down