Skip to content

Commit

Permalink
Deploy wasm to pages
Browse files Browse the repository at this point in the history
  • Loading branch information
widberg committed Dec 31, 2023
1 parent 4b25d4e commit 9a15df2
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 25 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Build wasm

on: [push, pull_request]

jobs:
build:
name: Build for wasm
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1

- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.74.1
targets: wasm32-unknown-unknown

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.0

- name: Download wasi-sdk
uses: suisei-cn/actions-download-file@v1.3.0
with:
url: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz"

- name: Install dependencies
run: |
mkdir -p ${{ github.workspace }}/wasi-sdk/ && tar -xzvf wasi-sdk-20.0-linux.tar.gz --strip-components=1 -C ${{ github.workspace }}/wasi-sdk/
cargo install trunk
- name: Build
run: trunk build --release
env:
CC: "${{ github.workspace }}/wasi-sdk/bin/clang --sysroot=${{ github.workspace }}/wasi-sdk/share/wasi-sysroot"
working-directory: ${{ github.workspace }}/bff-gui/

- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ github.workspace }}/bff-gui/dist/

deploy:
needs: build

permissions:
pages: write
id-token: write

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
26 changes: 3 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@ jobs:
bin_extension: .exe
- name: macos
os: macos-latest
- name: wasm
os: ubuntu-latest
target: wasm32-unknown-unknown

steps:
- uses: actions/checkout@v1

- uses: dtolnay/rust-toolchain@stable
with:
profile: minimal
toolchain: 1.74.1
targets: ${{ matrix.target }}

- name: Rust Cache
uses: Swatinem/rust-cache@v2.7.0
Expand All @@ -36,25 +31,10 @@ jobs:
run: sudo apt-get -y install libgtk-3-dev libasound2-dev
if: matrix.name == 'linux'

- name: Download wasi-sdk (wasm)
uses: suisei-cn/actions-download-file@v1.3.0
with:
url: "https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz"
if: matrix.name == 'wasm'

- name: Install dependencies (wasm)
run: |
mkdir -p ${{ github.workspace }}/wasi-sdk/ && tar -xzvf wasi-sdk-20.0-linux.tar.gz --strip-components=1 -C ${{ github.workspace }}/wasi-sdk/
cargo install trunk
if: matrix.name == 'wasm'

- name: Build
run: cmake -E env CARGO_PROFILE_RELEASE_LTO=true cargo build --release --locked --bins
if: matrix.name != 'wasm'

- name: Build (wasm)
run: /usr/bin/env -C bff-gui CC="${{ github.workspace }}/wasi-sdk/bin/clang --sysroot=${{ github.workspace }}/wasi-sdk/share/wasi-sysroot" trunk build --release
if: matrix.name == 'wasm'
run: cargo build --release --locked --bins
env:
CARGO_PROFILE_RELEASE_LTO: "true"

- name: Archive Artifacts
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
# data
/data/

/bff-gui/dist
/bff-gui/node_modules
# bff-gui
/bff-gui/dist/

# cargo flamegraph
/flamegraph.svg

0 comments on commit 9a15df2

Please sign in to comment.