Skip to content

Commit

Permalink
extract version update
Browse files Browse the repository at this point in the history
  • Loading branch information
qdrvm-ci committed Oct 15, 2024
1 parent f44fdb6 commit 29876c0
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions housekeeping/docker/kagome-dev/get_wasmedge_version.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
import re
import sys

def extract_version_and_sha(config_file_path, package_name):

def extract_version(config_file_path, package_name):
with open(config_file_path, 'r') as file:
content = file.read()

version_pattern = re.compile(r'hunter_config\(\s*' + re.escape(package_name) + r'\s*.*?URL\s+.*?/tags/([^\s/]+)\.zip', re.DOTALL)
sha_pattern = re.compile(r'hunter_config\(\s*' + re.escape(package_name) + r'\s*.*?SHA1\s+(\w+)', re.DOTALL)

version_pattern = re.compile(r'hunter_config\(\s*' + re.escape(package_name) + r'\s*.*?URL\s+.*?/heads/.*?/([^\s/]+)\.zip', re.DOTALL)
version_match = version_pattern.search(content)
sha_match = sha_pattern.search(content)

version = version_match.group(1) if version_match else None
return version


def extract_sha(cmakelists_file_path):
with open(cmakelists_file_path, 'r') as file:
content = file.read()

sha_pattern = re.compile(r'set\s*\(\s*WASMEDGE_ID\s*([a-fA-F0-9]+)\s*\)')
sha_match = sha_pattern.search(content)

sha = sha_match.group(1)[:7] if sha_match else None
return sha

return version, sha

if __name__ == "__main__":
config_file_path = '../../../cmake/Hunter/config.cmake'
cmakelists_file_path = '../../../CMakeLists.txt'
package_name = 'WasmEdge'

version, sha = extract_version_and_sha(config_file_path, package_name)
print(f"{version}-{sha}")

version = extract_version(config_file_path, package_name)

sha = extract_sha(cmakelists_file_path)

if version and sha:
print(f"{version}-{sha}")
else:
print("Failed to extract version and SHA")

0 comments on commit 29876c0

Please sign in to comment.