From 79814037ee01dd1786ca4e469fcb0852cba47628 Mon Sep 17 00:00:00 2001 From: streamcode9 Date: Sun, 21 Sep 2025 18:18:55 +0200 Subject: [PATCH] Fix wasi-sdk download format --- .github/workflows/build-wasm.yml | 38 ++++++++++++++++++++++++++++++++ wasm/hello.c | 7 ++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/workflows/build-wasm.yml create mode 100644 wasm/hello.c diff --git a/.github/workflows/build-wasm.yml b/.github/workflows/build-wasm.yml new file mode 100644 index 0000000..2ffb7aa --- /dev/null +++ b/.github/workflows/build-wasm.yml @@ -0,0 +1,38 @@ +name: Build WebAssembly Hello World + +on: + push: + branches: ["main"] + pull_request: + branches: ["main"] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Download wasi-sdk + run: | + WASI_VERSION=20.0 + WASI_RELEASE="wasi-sdk-${WASI_VERSION}" + WASI_PACKAGE="${WASI_RELEASE}-linux.tar.xz" + curl -L "https://github.com/WebAssembly/wasi-sdk/releases/download/${WASI_RELEASE}/${WASI_PACKAGE}" -o wasi-sdk.tar.xz + tar -xJf wasi-sdk.tar.xz + mv "${WASI_RELEASE}" wasi-sdk + + - name: Compile C89 hello world to WebAssembly + run: | + ./wasi-sdk/bin/clang \ + --sysroot=./wasi-sdk/share/wasi-sysroot \ + -std=c89 \ + wasm/hello.c \ + -o wasm/hello.wasm + + - name: Upload WebAssembly artifact + uses: actions/upload-artifact@v4 + with: + name: hello-wasm + path: wasm/hello.wasm diff --git a/wasm/hello.c b/wasm/hello.c new file mode 100644 index 0000000..f3b4f7b --- /dev/null +++ b/wasm/hello.c @@ -0,0 +1,7 @@ +#include + +int main(void) +{ + printf("Hello, world!\n"); + return 0; +}