Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 98 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: Build and Deploy to GitHub Pages

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
# Build the WASM package and web application
build-web:
name: Build Web Application
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Install wasm-pack
run: cargo install wasm-pack

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'

- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
wasm/target
key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-wasm-

- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: web/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('web/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Build WASM package
env:
RUSTFLAGS: '--cfg getrandom_backend="wasm_js" -C target-feature=+bulk-memory,+mutable-globals,+simd128'
run: |
cd wasm
wasm-pack build --target web --out-dir ../web/src/pkg

- name: Install npm dependencies
run: |
cd web
npm install

- name: Build web application
run: |
cd web
npm run build

- name: Upload artifact for GitHub Pages
if: github.event_name != 'pull_request'
uses: actions/upload-pages-artifact@v3
with:
path: web/dist

# Deploy to GitHub Pages
deploy:
name: Deploy to GitHub Pages
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/main'
needs: build-web
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,19 @@ doc/
# Log files
*.log
logs/

# Node.js / Web
node_modules/
web/node_modules/
web/dist/
web/src/pkg/
.npm
npm-debug.log*

# WASM build artifacts
wasm/pkg/
wasm/target/
*.wasm

# Server build artifacts
server/target/
Loading