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