Skip to content

Commit 937149a

Browse files
committed
Get the WASI SDK version to install in CI via the official action and Platforms/WASI/config.toml
1 parent b6d8aa4 commit 937149a

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

.github/workflows/reusable-wasi.yml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ jobs:
1313
timeout-minutes: 60
1414
env:
1515
WASMTIME_VERSION: 38.0.3
16-
WASI_SDK_VERSION: 29
17-
WASI_SDK_PATH: /opt/wasi-sdk
1816
CROSS_BUILD_PYTHON: cross-build/build
1917
CROSS_BUILD_WASI: cross-build/wasm32-wasip1
2018
steps:
@@ -26,18 +24,22 @@ jobs:
2624
uses: bytecodealliance/actions/wasmtime/setup@v1
2725
with:
2826
version: ${{ env.WASMTIME_VERSION }}
29-
- name: "Restore WASI SDK"
30-
id: cache-wasi-sdk
31-
uses: actions/cache@v5
32-
with:
33-
path: ${{ env.WASI_SDK_PATH }}
34-
key: ${{ runner.os }}-wasi-sdk-${{ env.WASI_SDK_VERSION }}
35-
- name: "Install WASI SDK" # Hard-coded to x64.
36-
if: steps.cache-wasi-sdk.outputs.cache-hit != 'true'
27+
- name: "Read WASI SDK version"
28+
id: wasi-sdk-version
3729
run: |
38-
mkdir "${WASI_SDK_PATH}" && \
39-
curl -s -S --location "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-arm64-linux.tar.gz" | \
40-
tar --strip-components 1 --directory "${WASI_SDK_PATH}" --extract --gunzip
30+
import tomllib
31+
from pathlib import Path
32+
import os
33+
config = tomllib.loads(Path("Platforms/WASI/config.toml").read_text())
34+
version = config["targets"]["wasi-sdk"]
35+
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
36+
f.write(f"version={version}\n")
37+
shell: python
38+
- name: "Install WASI SDK"
39+
id: install-wasi-sdk
40+
uses: bytecodealliance/setup-wasi-sdk-action@v3
41+
with:
42+
version: ${{ steps.wasi-sdk-version.outputs.version }}
4143
- name: "Add ccache to PATH"
4244
run: echo "PATH=/usr/lib/ccache:$PATH" >> "$GITHUB_ENV"
4345
- name: "Install Python"
@@ -53,6 +55,8 @@ jobs:
5355
- name: "Configure host"
5456
# `--with-pydebug` inferred from configure-build-python
5557
run: python3 Platforms/WASI configure-host -- --config-cache
58+
env:
59+
WASI_SDK_PATH: ${{ steps.install-wasi-sdk.outputs.wasi-sdk-path }}
5660
- name: "Make host"
5761
run: python3 Platforms/WASI make-host
5862
- name: "Display build info"

0 commit comments

Comments
 (0)