check_latest_versions.py 1.3 KB

123456789101112131415161718192021222324252627282930313233
  1. import sys
  2. import os
  3. import modules.version_manipulation as ndvm
  4. import modules.github_actions as cigh
  5. def main(command_line_args):
  6. """
  7. Inputs: Single version or multiple versions
  8. Outputs:
  9. Create files with the versions that needed update under temp_dir/staging-new-releases
  10. Setting the GitHub outputs, 'versions_needs_update' to 'true'
  11. """
  12. versions = [str(arg) for arg in command_line_args]
  13. # Create a temp output folder for the release that need update
  14. staging = os.path.join(os.environ.get('TMPDIR', '/tmp'), 'staging-new-releases')
  15. os.makedirs(staging, exist_ok=True)
  16. for version in versions:
  17. temp_value = ndvm.compare_version_with_remote(version)
  18. if temp_value:
  19. path, filename = ndvm.get_release_path_and_filename(version)
  20. release_path = os.path.join(staging, path)
  21. os.makedirs(release_path, exist_ok=True)
  22. file_release_path = os.path.join(release_path, filename)
  23. with open(file_release_path, "w") as file:
  24. print("Creating local copy of the release version update at: ", file_release_path)
  25. file.write(version)
  26. if cigh.run_as_github_action():
  27. cigh.update_github_output("versions_needs_update", "true")
  28. if __name__ == "__main__":
  29. main(sys.argv[1:])