Skip to content

Commit

Permalink
adapted code to fit to the new os-specific construct.yaml files (#605)
Browse files Browse the repository at this point in the history
  • Loading branch information
lufre1 authored May 13, 2024
1 parent fab3249 commit 875d614
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions deployment/version_getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@

yaml = ruamel.yaml.YAML()
yaml.preserve_quotes = True
ctor_fname = os.path.join("construct.yaml")

with open(ctor_fname, "r") as stream:
# Get the current OS name from the environment variable
current_os = os.environ.get('RUNNER_OS').lower() # Ensure lowercase for comparison

# Construct the filename based on OS name (consider all possibilities)
if current_os == 'windows':
construct_file = os.path.join("construct_windows-latest.yaml")
elif current_os == 'linux':
construct_file = os.path.join("construct_ubuntu-latest.yaml") # Assuming ubuntu-latest for Linux
# Add an else block if you plan to support macOS in the future
else:
raise Exception(f"Unsupported OS: {current_os}")

# Load YAML using ruamel.yaml
yaml = ruamel.yaml.YAML()
yaml.preserve_quotes = True

with open(construct_file, "r") as stream:
ctor_conf = yaml.load(stream)

ctor_conf["version"] = runpy.run_path(os.path.join("..", "micro_sam", "__version__.py"))["__version__"]

with open(ctor_fname, "w") as outfile:
yaml.dump(ctor_conf, outfile)
with open(construct_file, "w") as outfile:
yaml.dump(ctor_conf, outfile)

0 comments on commit 875d614

Please sign in to comment.