Skip to content

Commit

Permalink
Add workflow to automatically build WASM files (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mqxx committed Feb 24, 2024
1 parent 412a4eb commit c887e17
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build_wasm.yml
Original file line number Diff line number Diff line change
@@ -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/*
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
rustup component add clippy
cargo clippy --features=macro -- -D warnings
boostrap:
bootstrap:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ lto = true
codegen-units = 1
panic = 'abort'
strip = true

7 changes: 5 additions & 2 deletions crates/lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ 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
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 }
Expand All @@ -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"]
Expand Down

0 comments on commit c887e17

Please sign in to comment.