diff --git a/.github/scripts/build_assets/github_env.py b/.github/scripts/build_assets/github_env.py index 652983721e..3986c85a57 100644 --- a/.github/scripts/build_assets/github_env.py +++ b/.github/scripts/build_assets/github_env.py @@ -1,4 +1,5 @@ import os +import platform def set_env_var(key: str, value: str, delimiter: str='~'): @@ -6,19 +7,27 @@ def set_env_var(key: str, value: str, delimiter: str='~'): Set the GitHub env variable of 'key' to 'value' using the method specified here: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable + Support both Windows and Ubuntu machines provided by GitHub Actions. - Note: This assumes that we are on a Windows machine. :param: key, the name of the env variable. :param: value, the value of the env variable. :param: delimiter, the delimiter that you want to use to write to the file. Only applicable if the 'value' contains '\n' character aka a multiline string. """ - print('echo "{key}={value}" >> %GITHUB_ENV%') + print(platform.system()) - if "\n" in value: - os.system(f'echo "{key}<<{delimiter}" >> %GITHUB_ENV%') - os.system(f'echo {value} >> %GITHUB_ENV%') - os.system(f'echo "{delimiter}" >> %GITHUB_ENV%') + if platform.system() == "Windows": + if "\n" in value: + os.system(f'echo "{key}<<{delimiter}" >> %GITHUB_ENV%') + os.system(f'echo {value} >> %GITHUB_ENV%') + os.system(f'echo "{delimiter}" >> %GITHUB_ENV%') + else: + os.system(f'echo "{key}={value}" >> %GITHUB_ENV%') else: - os.system(f'echo "{key}={value}" >> %GITHUB_ENV%') \ No newline at end of file + if "\n" in value: + os.system(f'echo "{key}<<{delimiter}" >> $GITHUB_ENV') + os.system(f'echo {value} >> $GITHUB_ENV') + os.system(f'echo "{delimiter}" >> $GITHUB_ENV') + else: + os.system(f'echo "{key}={value}" >> $GITHUB_ENV') \ No newline at end of file