From ed37d35c54983b061f00ec781e0a3929c9beab66 Mon Sep 17 00:00:00 2001 From: tobozo Date: Fri, 10 Nov 2023 13:21:09 +0000 Subject: [PATCH] build+publish wasm example to github-pages followup for #470 --- .github/workflows/SDLBuild.yml | 47 +++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/.github/workflows/SDLBuild.yml b/.github/workflows/SDLBuild.yml index 1b920915..9f82e084 100644 --- a/.github/workflows/SDLBuild.yml +++ b/.github/workflows/SDLBuild.yml @@ -3,6 +3,7 @@ name: SDLBuild env: PROJECT_DIR: examples_for_PC/CMake_SDL + WASM_DIR: examples_for_PC/CMake_WASM on: @@ -20,6 +21,17 @@ on: workflow_dispatch: +permissions: + contents: write + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + jobs: LGFX_SDL2: @@ -68,7 +80,6 @@ jobs: cmake --build build/release --config Release - - name: Build LGFX_SDL2 for Linux if: ${{ matrix.os == 'ubuntu-latest' }} run: | @@ -81,6 +92,28 @@ jobs: cmake .. cmake --build . + - name: Build LGFX_SDL2/WASM for Linux + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + git clone https://github.com/emscripten-core/emsdk.git + cd emsdk + ./emsdk install latest # any specific version? + ./emsdk activate latest + source ./emsdk_env.sh + cd .. + cd ${{env.WASM_DIR}} + mkdir build + cd build + emcmake cmake .. + emmake make + mkdir -p www/WASM + cp index.html www/WASM/index.html + + - name: Upload WASM artifact + if: ${{ matrix.os == 'ubuntu-latest' }} + uses: actions/upload-pages-artifact@v2 + with: + path: ${{env.WASM_DIR}}/build/www - name: Build LGFX_SDL2 for Mac @@ -94,3 +127,15 @@ jobs: cmake .. cmake --build . + + deploy: + name: Deploy WASM Example 🚀 + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: LGFX_SDL2 + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2