Skip to content

Fix + clean

Fix + clean #12

Workflow file for this run

name: Github pages
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --cfg=web_sys_unstable_apis # This flag is required because wgpu is still unstable on wasm.
jobs:
build:
# What's installed
# https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Add target
run: rustup target add wasm32-unknown-unknown
- name: Build WASM
run: cargo build --release --lib --target wasm32-unknown-unknown --no-default-features --verbose
- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli
- name: Run tests
run: cargo test --lib --target wasm32-unknown-unknown --no-default-features --verbose
- name: Generate JS
run: wasm-bindgen target/wasm32-unknown-unknown/release/protos_rs.wasm --out-dir web/public/scripts --out-name protos_rs --target no-modules --no-typescript
- name: Install wasm-opt
run: cargo install wasm-opt
- name: Optimize WASM
run: wasm-opt target/wasm32-unknown-unknown/release/protos_rs.wasm -O2 --fast-math -o target/wasm32-unknown-unknown/release/protos_rs.wasm
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./web/public/
deploy:
# Add a dependency to the build job
needs: build
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action