diff --git a/.github/scripts/build-web.sh b/.github/scripts/build-web.sh new file mode 100644 index 0000000..c20b869 --- /dev/null +++ b/.github/scripts/build-web.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -eo pipefail + +REPO_ROOT="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)" +EMSDK_DIR="${RUNNER_TEMP:-$(dirname "$REPO_ROOT")}/emsdk" +BUILD_DIR="$REPO_ROOT/build" + +if [ "$1" = "release" ]; then + BUILD_TYPE="Release" +else + BUILD_TYPE="Debug" +fi + +git clone https://github.com/emscripten-core/emsdk.git --depth 1 "$EMSDK_DIR" +( +cd "$EMSDK_DIR" +./emsdk install latest +./emsdk activate latest +) +source "$EMSDK_DIR"/emsdk_env.sh +emcmake cmake -S "$REPO_ROOT" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" +cmake --build "$BUILD_DIR" --config "${BUILD_TYPE}" --parallel $(nproc) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index d6166cc..1c48362 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -51,7 +51,7 @@ jobs: c_compiler: cl steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 with: submodules: true @@ -95,6 +95,40 @@ jobs: # A file, directory or wildcard pattern that describes what to upload path: ${{ steps.strings.outputs.build-output-dir }}/examples/win32/${{ matrix.build_type }}/libspnavdev_test.exe + build_web: + needs: build + name: Build Release Web + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - name: Build & Pack + run: | + .github/scripts/build-web.sh release + cd build/examples/web + rm -rf CMakeFiles || true + - name: Upload web version as artifact + id: upload_web + uses: actions/upload-pages-artifact@v3 + with: + path: build/examples/web/ + + deploy_web: + # If you want deployment only on pushes to master (not manual runs on master), use: + # if: github.event_name == 'push' && github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' + needs: build_web + 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 + upload_release_assets: name: Upload Release Assets needs: [build]