Skip to content

Commit

Permalink
rename major_release to wis2box_version for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
maaikelimper committed Jan 14, 2025
1 parent 5823fc3 commit cd9aa8f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions wis2box-ctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ def build_local_images() -> None:
run(split(f'docker build -t ghcr.io/wmo-im/{image}:local {image}'))
return None

def get_latest_release_tag(image: str, major_release: str = '') -> str:
def get_latest_release_tag(image: str, wis2box_version: str = '') -> str:
"""
Fetches the latest release tag for a GitHub repository.
:param image: required, string. The name of the image repository.
:param major_release: required, string. The major release version.
:param wis2box_version: required, string. The major release version.
:return: The latest release tag or an error message if not found.
"""
url = f'https://api.github.com/repos/wmo-im/{image}/releases'
headers = {'Accept': 'application/vnd.github.v3+json'}

print(f'Fetching latest release tag from GitHub for {image} using wis2box-version={major_release}')
print(f'Fetching latest release tag from GitHub for {image} using wis2box-version={wis2box_version}')

options = []
try:
Expand All @@ -147,7 +147,7 @@ def get_latest_release_tag(image: str, major_release: str = '') -> str:
releases = response.json()
for release in releases:
print(release['tag_name'])
if major_release in release['tag_name']:
if wis2box_version in release['tag_name']:
options.append(release['tag_name'])
else:
print(f'Error fetching latest release tag for {image}: {response.status_code}')
Expand All @@ -156,7 +156,7 @@ def get_latest_release_tag(image: str, major_release: str = '') -> str:

# throw error if options is empty
if not options:
raise ValueError(f'No release tags found for {image} with major release {major_release}')
raise ValueError(f'No release tags found for {image} with major release {wis2box_version}')

# sort descending and return the first element
options.sort(reverse=True)
Expand Down

0 comments on commit cd9aa8f

Please sign in to comment.