Skip to content

Commit a8f81cb

Browse files
authored
Fix wasi-sdk download format (#11)
1 parent 0afe746 commit a8f81cb

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/build-wasm.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Build WebAssembly Hello World
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out repository
15+
uses: actions/checkout@v4
16+
17+
- name: Download wasi-sdk
18+
run: |
19+
WASI_VERSION=20.0
20+
WASI_RELEASE="wasi-sdk-${WASI_VERSION}"
21+
WASI_PACKAGE="${WASI_RELEASE}-linux.tar.xz"
22+
curl -L "https://github.com/WebAssembly/wasi-sdk/releases/download/${WASI_RELEASE}/${WASI_PACKAGE}" -o wasi-sdk.tar.xz
23+
tar -xJf wasi-sdk.tar.xz
24+
mv "${WASI_RELEASE}" wasi-sdk
25+
26+
- name: Compile C89 hello world to WebAssembly
27+
run: |
28+
./wasi-sdk/bin/clang \
29+
--sysroot=./wasi-sdk/share/wasi-sysroot \
30+
-std=c89 \
31+
wasm/hello.c \
32+
-o wasm/hello.wasm
33+
34+
- name: Upload WebAssembly artifact
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: hello-wasm
38+
path: wasm/hello.wasm

wasm/hello.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdio.h>
2+
3+
int main(void)
4+
{
5+
printf("Hello, world!\n");
6+
return 0;
7+
}

0 commit comments

Comments
 (0)