enable wasm builds and automatically deploy the builds to github pages #40
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
# Run cargo test | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
name: Test `cargo test` on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ matrix.os }}-cargo-test | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install Dependencies | |
if: matrix.os == 'ubuntu-latest' | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libopenxr-loader1 libopenxr-dev | |
- name: Run cargo test | |
run: cargo test | |
- name: Install wasm libcore/libstd | |
if: matrix.os == 'ubuntu-latest' | |
run: rustup target install wasm32-unknown-unknown | |
- name: Install wasm-bindgen | |
if: matrix.os == 'ubuntu-latest' | |
run: cargo install wasm-bindgen-cli | |
- name: Build wasm | |
if: matrix.os == 'ubuntu-latest' | |
run: cargo build --release --target wasm32-unknown-unknown --bin demo && wasm-bindgen --out-dir ./web/ --target web ./target/wasm32-unknown-unknown/release/demo.wasm | |
- name: Push to gh-pages | |
if: matrix.os == 'ubuntu-latest' | |
uses: s0/git-publish-subdir-action@develop | |
env: | |
SQUASH_HISTORY: true | |
REPO: self | |
BRANCH: gh-pages # The branch name where you want to push the assets | |
FOLDER: web # The directory where your assets are generated | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub will automatically add this - you don't need to bother getting a token | |
MESSAGE: "Build: ({sha}) {msg}" # The commit message | |
# Run cargo clippy -- -D warnings | |
clippy: | |
name: Clippy | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-cargo-clippy | |
- name: Add clippy to rustup | |
run: rustup component add clippy | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev | |
- name: Run clippy | |
run: cargo clippy -- -D warnings | |
# Run cargo fmt --all -- --check | |
format: | |
name: Format | |
runs-on: ubuntu-latest | |
timeout-minutes: 30 | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v4 | |
- name: Add rustfmt to rustup | |
run: rustup component add rustfmt | |
- name: Run cargo fmt | |
run: cargo fmt --all -- --check | |
android: | |
runs-on: ubuntu-latest | |
timeout-minutes: 40 | |
steps: | |
- name: Install Dependencies | |
run: sudo apt-get update; sudo apt-get install pkg-config libx11-dev libasound2-dev libudev-dev lld llvm | |
- uses: actions/checkout@v4 | |
- run: git submodule update --init | |
- name: Cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
key: ${{ runner.os }}-android | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Add Android targets | |
run: rustup target add aarch64-linux-android armv7-linux-androideabi | |
- name: Install cargo-binstall | |
run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash | |
- name: Install xbuild | |
run: cargo binstall --git https://github.com/NiklasEi/xbuild --bin-dir x xbuild -y | |
- name: show deps | |
run: x doctor | |
- name: Build app bundle | |
run: x build --release --platform android --format apk --arch arm64 |