From 5bb1623de80b5f9229174447870f23e04a108efa Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 23 Jan 2024 14:10:32 +0100 Subject: [PATCH] Added Workflow for building WASM bindings --- .github/workflows/build_wasm.yml | 37 ++++++++++++++++++++++++++++++++ Cargo.toml | 13 +++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/build_wasm.yml diff --git a/.github/workflows/build_wasm.yml b/.github/workflows/build_wasm.yml new file mode 100644 index 00000000..d76d7df5 --- /dev/null +++ b/.github/workflows/build_wasm.yml @@ -0,0 +1,37 @@ +name: 'Build WebAssembly' + +on: + push: + branches: + - master + + workflow_dispatch: + inputs: + build: + description: 'Build WASM files.' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v3 + + - name: 'Install wasm-pack' + run: | + curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + export PATH="$HOME/.cargo/bin:$PATH" + + - name: 'Build WebAssembly' + run: | + rustup target add wasm32-unknown-unknown + wasm-pack build --release --target web --out-name index + mkdir -p artifacts + find pkg -type f \( -name "*.js" -o -name "*.d.ts" -o -name "*.wasm" \) -exec cp {} artifacts \; + + - name: 'Upload Artifacts' + uses: actions/upload-artifact@v3 + with: + name: 'wasm' + path: artifacts/* diff --git a/Cargo.toml b/Cargo.toml index 2598e479..ccf10c3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,3 +18,16 @@ lto = true codegen-units = 1 panic = 'abort' strip = true + +[package] +name = 'grass-wasm' +edition = "2021" + +[lib] +path = "crates/lib/src/lib.rs" +crate-type = ["cdylib"] + +[dependencies] +wasm-bindgen = "0.2" +grass_compiler = { path = "crates/compiler" } +getrandom = { version = "0.2", features = ["js"] }