Installs wasm-pack, binaryen, and wasm-opt in your GitHub Actions workflows. No more manually managing WebAssembly toolchain downloads.
- Downloads and installs wasm-pack and all binaryen tools
- Works on Linux, macOS, and Windows (x86_64 + ARM64)
- Caches tools between runs to keep builds fast
- Automatically adds tools to PATH
- Handles version pinning or uses latest releases
wasm-pack - The standard Rust to WebAssembly build tool
binaryen tools - Complete WebAssembly optimization suite:
wasm-opt- WebAssembly optimizer (the main one you probably want)wasm-as- WebAssembly assemblerwasm-dis- WebAssembly disassemblerwasm2js- WebAssembly to JavaScript compilerwasm-reduce- Testcase reducer for debuggingwasm-shell- WebAssembly interpreter- Plus other specialized tools (
wasm-emscripten-finalize,wasm-ctor-eval, etc.)
- name: Install wasm tools
uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0
- name: Build WebAssembly
run: |
wasm-pack build --target web --release
wasm-opt --version- name: Install specific versions
uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0
with:
binaryen-version: '118' # or 'latest'
wasm-pack-version: '0.13.0' # or 'latest'Tools are cached automatically to avoid re-downloading on every run:
- First run: ~30-60 seconds (download + install)
- Cached runs: ~5-10 seconds (restore from cache)
Cache keys include OS, architecture, and tool versions, so you'll get a fresh download when versions change but hit the cache otherwise.
Example cache key: wasm-tools-linux-x86_64-v0.13.0-version_118
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0
- run: |
wasm-pack --version
wasm-opt --version| Input | Description | Default |
|---|---|---|
wasm-pack-version |
wasm-pack version (latest or specific like 0.13.0) |
latest |
binaryen-version |
binaryen version (latest or specific like 118) |
latest |
| OS | x86_64 | ARM64 |
|---|---|---|
| Linux | ✅ | ✅ |
| macOS | ✅ | ✅ (M1/M2) |
| Windows | ✅ | ❌ |
name: Build WASM
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Cache Rust deps
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: rust-${{ hashFiles('**/Cargo.lock') }}
- name: Install WASM tools
uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0
- name: Build and optimize
run: |
wasm-pack build --target web --out-dir pkg
wasm-opt pkg/my_project_bg.wasm -O3 -o pkg/my_project_bg.wasmname: Build with WASM optimization
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'
cache: 'npm'
- uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0
- name: Build and optimize
run: |
npm ci
npm run build
# Optimize any .wasm files we generated
find dist -name "*.wasm" -exec wasm-opt {} -O3 -o {} \;If wasm-pack or wasm-opt aren't found after installation:
- name: Debug PATH
run: |
echo $PATH
which wasm-pack || echo "wasm-pack not found"
which wasm-opt || echo "wasm-opt not found"- name: Debug with fresh install
run: echo "cache-bust-$(date +%s)" >> $GITHUB_ENV
- uses: romarketplace-com/wasm-pack-dev-toolchain@v1.0.0Or clear the cache manually in your repo's Actions tab.
The action will list available release assets if it can't find the right download. Check the output and compare with:
PRs welcome. For big changes, open an issue first.
This project is built with TypeScript and packaged as a GitHub Action. To set up your development environment:
-
Clone the repository:
git clone https://github.com/romarketplace-com/wasm-pack-dev-toolchain-installer.git cd wasm-pack-dev-toolchain-installer -
Install dependencies:
npm install # or yarn -
Build commands:
# Compile TypeScript to JavaScript npm run build # or yarn build # Format code with Biome npm run format:write # or yarn format:write # Lint code npm run lint # or yarn lint:fix # Package the action with ncc npm run pack # or yarn pack # Run all build steps in sequence npm run all # or yarn all
-
Testing locally with act:
# Install act if you haven't already # Then run your action locally act -j <job-name>
src/- TypeScript source codeindex.ts- Main entry point for the actiondependencies.ts- Logic for handling tool dependencies, downloads, and setup
dist/- Compiled TypeScript outputlib/- Packaged action code (produced bynpm run pack)action.yml- GitHub Action definitionexample/- Example Rust WebAssembly project for testing
- Make your code changes in the
src/directory - Run
npm run buildto compile TypeScript - Run
npm run lint:fixto ensure code style consistency - Run
npm run packto package the action using ncc - Test your changes locally with act
- Commit and push your changes
This project is licensed under the MIT License, for more information, check the LICENSE file.