Add workflow to automatically build WASM files (#92)

This commit is contained in:
Mqx 2024-02-24 06:24:23 +01:00 committed by GitHub
parent 412a4ebeb7
commit c887e17e2e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 3 deletions

35
.github/workflows/build_wasm.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: 'Build WebAssembly'
on:
push:
tags: [ '*' ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v4
- 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
pushd ./crates/lib
wasm-pack build --release --target web --out-name index
popd
mkdir -p artifacts
find crates/lib/pkg -type f \( -name "*.js" -o -name "*.d.ts" -o -name "*.wasm" \) -exec cp {} artifacts \;
- name: 'Upload Artifacts'
uses: actions/upload-artifact@v4
with:
name: 'wasm'
path: artifacts/*

View File

@ -50,7 +50,7 @@ jobs:
rustup component add clippy
cargo clippy --features=macro -- -D warnings
boostrap:
bootstrap:
runs-on: ubuntu-latest
steps:
- name: Checkout

View File

@ -18,3 +18,4 @@ lto = true
codegen-units = 1
panic = 'abort'
strip = true

View File

@ -21,9 +21,10 @@ required-features = ["commandline"]
[lib]
name = "grass"
path = "src/lib.rs"
# crate-type = ["cdylib", "rlib"]
crate-type = ["cdylib", "rlib"]
bench = false
[package.metadata.docs.rs]
# To build locally:
# RUSTDOCFLAGS="--cfg doc_cfg" cargo +nightly doc --features=macro --no-deps --open
@ -31,6 +32,8 @@ features = ["macro"]
rustdoc-args = ["--cfg", "doc_cfg"]
[dependencies]
wasm-bindgen = { version = "0.2", optional = true }
getrandom = { version = "0.2", features = ["js"] }
grass_compiler = { path = "../compiler", version = "=0.13.2", default-features = false }
include_sass = { path = "../include_sass", version = "0.13.2", optional = true }
clap = { version = "4.3.10", optional = true }
@ -41,7 +44,7 @@ default = ["commandline", "random"]
# Option (enabled by default): build a binary using clap
commandline = ["clap"]
random = ["grass_compiler/random"]
wasm-exports = ["grass_compiler/wasm-exports"]
wasm-exports = ["grass_compiler/wasm-exports", "wasm-bindgen"]
# Option: include the proc macro `include_sass!`
macro = ["include_sass"]
nightly = ["include_sass/nightly"]