@@ -62,7 +62,7 @@ def calculate_version_and_tag(version: str):
6262 return version , tag
6363
6464
65- def calculate_artifact_url (version : str , tag : str , arch : str , os : str ):
65+ def calculate_artifact_url (version : str , tag : str , arch : str , os_name : str ):
6666 """
6767 Generate the artifact URL based on the version, architecture, and operating system.
6868
@@ -72,13 +72,13 @@ def calculate_artifact_url(version: str, tag: str, arch: str, os: str):
7272 'https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-25.1/wasi-sdk-25.1-arm64-macos.tar.gz'
7373 """
7474 base = 'https://github.com/WebAssembly/wasi-sdk/releases/download'
75- if os == 'Darwin' :
76- os = 'macos'
75+ if os_name == 'Darwin' :
76+ os_name = 'macos'
7777 else :
78- os = os .lower ()
78+ os_name = os_name .lower ()
7979 if arch .lower () == 'amd64' :
8080 arch = 'x86_64'
81- return f'{ base } /{ tag } /wasi-sdk-{ version } -{ arch } -{ os } .tar.gz'
81+ return f'{ base } /{ tag } /wasi-sdk-{ version } -{ arch } -{ os_name } .tar.gz'
8282
8383
8484def install (url : str , install_dir : str ):
@@ -120,10 +120,21 @@ def install(url: str, install_dir: str):
120120 return clang_path , sysroot_path
121121
122122
123- def write_github_path (install_dir : str , version : str , clang_path : str , sysroot_path : str ):
123+ def write_github_env (install_dir : str , version : str ):
124124 """
125- Write the WASI SDK path to the GitHub Actions path file. This also updates the GitHub
126- environment for good measure.
125+ Write informational WASI SDK environment variables to GitHub Actions.
126+ """
127+ assert 'GITHUB_ENV' in os .environ , "GITHUB_ENV environment variable must be set"
128+ env_file = os .environ ['GITHUB_ENV' ]
129+ logging .info (f'Writing to GitHub environment file { env_file } ' )
130+ with open (env_file , 'a' ) as f :
131+ f .write (f'WASI_SDK_PATH={ install_dir } \n ' )
132+ f .write (f'WASI_SDK_VERSION={ version } \n ' )
133+
134+
135+ def write_github_path (install_dir : str , clang_path : str , sysroot_path : str ):
136+ """
137+ Write the WASI SDK bin directory to GitHub PATH and set CC/CXX environment variables.
127138 """
128139 assert 'GITHUB_PATH' in os .environ , "GITHUB_PATH environment variable must be set"
129140 path_file = os .environ ['GITHUB_PATH' ]
@@ -132,10 +143,8 @@ def write_github_path(install_dir: str, version: str, clang_path: str, sysroot_p
132143 f .write (os .path .dirname (clang_path ))
133144
134145 env_file = os .environ ['GITHUB_ENV' ]
135- logging .info (f'Writing to GitHub environment file { env_file } ' )
146+ logging .info (f'Writing CC/CXX to GitHub environment file { env_file } ' )
136147 with open (env_file , 'a' ) as f :
137- f .write (f'WASI_SDK_PATH={ install_dir } \n ' )
138- f .write (f'WASI_SDK_VERSION={ version } \n ' )
139148 f .write (f'CC={ clang_path } --sysroot={ sysroot_path } \n ' )
140149 f .write (f'CXX={ clang_path } ++ --sysroot={ sysroot_path } \n ' )
141150
@@ -162,8 +171,10 @@ def main(version: str, install_dir: str, add_to_path: bool):
162171
163172 clang_path , sysroot_path = install (url , install_dir )
164173
174+ if 'GITHUB_ENV' in os .environ :
175+ write_github_env (install_dir , version )
165176 if add_to_path :
166- write_github_path (install_dir , version , clang_path , sysroot_path )
177+ write_github_path (install_dir , clang_path , sysroot_path )
167178 if 'GITHUB_OUTPUT' in os .environ :
168179 write_github_output (install_dir , version , clang_path , sysroot_path )
169180
0 commit comments