Add deploy section. #11
This file contains hidden or 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: build | ||
| on: | ||
| push: | ||
| branches: | ||
| - 'main' | ||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| - uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| target/ | ||
| key: ${{ github.ref || github.run_id }} | ||
| - uses: dtolnay/rust-toolchain@stable | ||
| - name: Install wabt and binaryen | ||
| run: sudo apt-get update; sudo apt-get install wabt; sudo apt install binaryen | ||
| - uses: jetli/[email protected] | ||
| with: | ||
| version: 'latest' | ||
| - name: Install wasm target | ||
| run: rustup target install wasm32-unknown-unknown | ||
| - name: Build | ||
| run: cargo build --release --target wasm32-unknown-unknown | ||
| - name: wasm-bindgen | ||
| run: wasm-bindgen --no-typescript --out-dir ./out/ --target web ./target/wasm32-unknown-unknown/release/tabletop.wasm --out-name "tabletop" | ||
| - name: wasm-strip | ||
| run: wasm-strip ./out/tabletop_bg.wasm | ||
| - name: wasm-opt | ||
| run: wasm-opt -Oz --enable-bulk-memory --enable-nontrapping-float-to-int --enable-reference-types --enable-sign-ext -o ./out/tabletop_bg.wasm ./out/tabletop_bg.wasm | ||
| - name: gzip | ||
| run: gzip -f ./out/tabletop_bg.wasm | ||
| - name: Copy | ||
| run: cp -R assets out/ && cp www/index.html out/index.html | ||
| - name: Push | ||
| 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: out # 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 | ||
| - name: Setup Pages | ||
| uses: actions/configure-pages@v5 | ||
| - name: Upload artifact | ||
| uses: actions/upload-pages-artifact@v4 | ||
| with: | ||
| path: "./out" | ||
| deploy: | ||
| need: build | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pages: write | ||
| id-token: write | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v4 | ||