fix dep; improve deploy #6
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
# tags: | |
# pull_request: | |
env: | |
CARGO_TERM_COLOR: always | |
# if a test fails, shows the backtrace | |
RUST_BACKTRACE: 1 | |
# if depending on a ssh crate, use the git cli. | |
CARGO_NET_GIT_FETCH_WITH_CLI: true | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# permissions: | |
# contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
# rust compiler for creating binaries | |
- name: Install latest nightly (for wasm) | |
uses: dtolnay/rust-toolchain@nightly | |
with: | |
targets: wasm32-unknown-unknown | |
components: rustfmt, clippy | |
- name: Install Wasm Target | |
run: | | |
set -e | |
rustup target add wasm32-unknown-unknown | |
# Runs some Rust-related caching | |
- uses: Swatinem/rust-cache@v2 | |
- name: Download wasm-pack | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
# wasm-pack build --release also optimizes the wasm binary | |
- name: Build Release wasm | |
run: wasm-pack build --release --target web --no-default-features --features "wasm_yew_ui" | |
- name: Prepare Wasm Deploy | |
run: | | |
set -e | |
# Prepare the publishing structure | |
mkdir -p publish/ | |
# move assets | |
mv index.html publish/ | |
mv index.js publish/ | |
mv pkg/ publish/pkg/ | |
# rm gitignore | |
rm publish/pkg/.gitignore | |
# Publish | |
- name: Frontend Deploy | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_branch: gh-pages | |
publish_dir: ./publish | |
keep_files: false |