Skip to content

Commit

Permalink
Update update_gear_version.py
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyfilyanin authored Nov 27, 2024
1 parent 9111508 commit df66fb1
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions scripts/update_gear_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def get_latest_semver_tag(repo_url, prefix=''):
response.raise_for_status()
tags = response.json()

# Build the regex pattern based on the prefix
if prefix:
pattern = r'^' + re.escape(prefix) + r'\d+\.\d+\.\d+$'
else:
pattern = r'^\d+\.\d+\.\d+$'
# Print the raw tags to debug
print(f"Raw tags from {repo_url}: {tags}")

# Build the regex pattern to account for the optional prefix (empty for gear, 'rs/' for sails)
pattern = r'^' + re.escape(prefix) + r'\d+\.\d+\.\d+$'

# Filter out tags that are not valid semantic versions
valid_tags = [
Expand All @@ -29,7 +29,7 @@ def get_latest_semver_tag(repo_url, prefix=''):
print(f"No valid tags found in repository {repo_url}")
return None

# Remove prefix from the tags and sort by version
# Remove prefix and sort by version
valid_tags = [tag.lstrip(prefix) for tag in valid_tags]
valid_tags.sort(key=lambda s: version.parse(s.lstrip('v')), reverse=True)

Expand Down Expand Up @@ -66,14 +66,12 @@ def update_wf_contracts(file_path, gear_version):
file.write(content)

if __name__ == "__main__":
# Get the latest GEAR version
gear_version = get_latest_semver_tag(GEAR_REPO_TAGS_URL).lstrip('v') if get_latest_semver_tag(GEAR_REPO_TAGS_URL) else None
# Get the latest GEAR version (no 'rs/' prefix)
gear_version = get_latest_semver_tag(GEAR_REPO_TAGS_URL).lstrip('v')

# Get the latest SAILS version with 'rs/' prefix
sails_version = get_latest_semver_tag(SAILS_REPO_TAGS_URL, prefix='rs/').lstrip('v')

# Get the latest SAILS version, strip 'rs/' prefix
sails_version = get_latest_semver_tag(SAILS_REPO_TAGS_URL, prefix='rs/').lstrip('v') if get_latest_semver_tag(SAILS_REPO_TAGS_URL, prefix='rs/') else None

if gear_version and sails_version:
update_cargo_toml('../contracts/Cargo.toml', gear_version, sails_version)
update_wf_contracts('../.github/workflows/contracts-tests.yml', gear_version)
else:
print("Error: Could not find valid GEAR or SAILS version.")

0 comments on commit df66fb1

Please sign in to comment.