Update Readme.md #222
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy WebAssembly to Web Branch | |
on: | |
push: | |
branches: [main] | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Install Rust and wasm toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
profile: minimal | |
toolchain: stable | |
target: wasm32-unknown-unknown | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install wasm-bindgen | |
run: | | |
mkdir wasm-bindgen | |
curl -sSL "https://github.com/rustwasm/wasm-bindgen/releases/download/0.2.86/wasm-bindgen-0.2.86-x86_64-unknown-linux-musl.tar.gz" | tar xvz -C ./wasm-bindgen wasm-bindgen-0.2.86-x86_64-unknown-linux-musl --strip=1 | |
echo `pwd`/wasm-bindgen >> $GITHUB_PATH | |
- name: Install wasm-opt | |
run: | | |
mkdir binaryen | |
curl -sSL https://github.com/WebAssembly/binaryen/releases/download/version_111/binaryen-version_111-x86_64-linux.tar.gz | tar xvz -C ./binaryen binaryen-version_111 --strip=1 | |
echo `pwd`/binaryen/bin >> $GITHUB_PATH | |
- name : Build Wasm | |
run: RUSTFLAGS=--cfg=web_sys_unstable_apis cargo build --release --target wasm32-unknown-unknown | |
- name: Generate JavaScript bindings | |
run: wasm-bindgen --target web --no-typescript --out-dir out target/wasm32-unknown-unknown/release/velo.wasm | |
- name: Optimize Wasm | |
run : wasm-opt -Os out/velo_bg.wasm -o out/velo_bg.wasm | |
- name: Copy WebAssembly files to web branch | |
run: | | |
git config --global user.email "" | |
git config --global user.name "GitHub Actions" | |
git fetch --all | |
git checkout -b web origin/web -f | |
cp -r out/* . | |
rm -rf binaryen wasm-bindgen target out | |
git add . | |
git commit -m "Build and Deploy WebAssembly to Web Branch" || true | |
git push origin web |