Skip to content

Commit

Permalink
Add release build to web build job
Browse files Browse the repository at this point in the history
  • Loading branch information
Dove6 committed Aug 27, 2024
1 parent de8423a commit bd9d833
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
27 changes: 21 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
pull_request:
branches: ["main"]

permissions:
contents: write

env:
CARGO_TERM_COLOR: always

Expand Down Expand Up @@ -34,6 +37,9 @@ jobs:
run: cargo clippy --all --features bevy/x11 -- -Dwarnings
web:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./repo
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -44,18 +50,27 @@ jobs:
sudo apt-get install g++ pkg-config libx11-dev libasound2-dev libudev-dev libxkbcommon-x11-0
cargo install wasm-bindgen-cli
- uses: Swatinem/rust-cache@v2
with:
workspaces: "repo -> target"
- name: Build debug
working-directory: ./repo
run: cargo build --target wasm32-unknown-unknown --all --verbose -Zbuild-std=std,panic_abort
- name: Generate files for debug
run: wasm-bindgen --no-typescript --target web --out-dir ./out/debug/ --out-name "pixlib" ./target/wasm32-unknown-unknown/debug/pixlib.wasm
- name: Summarize size of out dir for debug
run: du -h ./out
run: |
mkdir -p ../out/debug
wasm-bindgen --no-typescript --target web --out-dir ../out/debug/ --out-name "pixlib" ./target/wasm32-unknown-unknown/debug/pixlib.wasm
- name: Build release
run: cargo build --profile release-small --target wasm32-unknown-unknown --all --verbose -Zbuild-std=std,panic_abort
- name: Generate files for release
run: |
mkdir -p ../out/release
wasm-bindgen --no-typescript --target web --out-dir ../out/release/ --out-name "pixlib" ./target/wasm32-unknown-unknown/release-small/pixlib.wasm
- name: Update gh-pages and push changes
working-directory: ./app
run: |
git config user.email "github-actions@github.com"
git config user.name "github-actions"
git clean -xdf
git checkout gh-pages
cp -R ../out/* .
git commit -am "Update files" && git push || echo "No changes to commit"
test ! -d ./target
git add .
git commit -m "Update files" && git push || echo "No changes to commit"
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[profile.release-small]
inherits = "release"
opt-level = 'z'
lto = "thin"

0 comments on commit bd9d833

Please sign in to comment.