test #20
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 ] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
target: [desktop, web] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Ubuntu | |
if: matrix.os == 'ubuntu-latest' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y xorg-dev libglu1-mesa-dev gcc g++ | |
- name: Enable Developer Command Prompt (Windows) | |
if: matrix.os == 'windows-latest' | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Setup CMake and Ninja | |
uses: lukka/get-cmake@latest | |
with: | |
useCloudCache: true | |
useLocalCache: false | |
cmakeVersion: "^3.24.0" | |
ninjaVersion: "^1.11.0" | |
- name: Setup Emscripten | |
if: matrix.target == 'web' | |
uses: mymindstorm/setup-emsdk@v14 | |
with: | |
version: 3.1.51 | |
- name: Export Emscripten environment | |
shell: bash | |
if: matrix.target == 'web' && matrix.os != 'windows-latest' | |
run: | | |
echo "EMSDK_ROOT=$EMSDK/upstream/emscripten" >> $GITHUB_ENV | |
echo "EMSDK_INCLUDE_ROOT=$EMSDK/upstream/emscripten/cache/sysroot/include" >> $GITHUB_ENV | |
- name: Export Emscripten environment (Windows) | |
if: matrix.target == 'web' && matrix.os == 'windows-latest' | |
run: | | |
echo "EMSDK_ROOT=$EMSDK/upstream/emscripten" >> $env:GITHUB_ENV | |
echo "EMSDK_INCLUDE_ROOT=$EMSDK/upstream/emscripten/cache/sysroot/include" >> $env:GITHUB_ENV | |
- name: Define compiler | |
shell: bash | |
run: | | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "CXX=g++" >> $GITHUB_ENV | |
echo "CC=gcc" >> $GITHUB_ENV | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
echo "CXX=clang++" >> $GITHUB_ENV | |
echo "CC=clang" >> $GITHUB_ENV | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
echo "CXX=cl" >> $GITHUB_ENV | |
echo "CC=cl" >> $GITHUB_ENV | |
else | |
echo "Unknown OS" | |
exit 1 | |
fi | |
- name: Configure | |
shell: bash | |
run: cmake --preset=${{ matrix.target }}-release -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX | |
- name: Build | |
run: cmake --build ./build --target=all | |
- name: Copy WASM module (Ubuntu) | |
if: matrix.target == 'web' && matrix.os == 'ubuntu-latest' | |
run: | | |
cp ./build/sandbox.wasm ./src/web | |
cp ./build/sandbox.js ./src/web | |
cp ./build/sandbox.html ./src/web | |
- name: Deploy to GitHub Pages (Ubuntu) | |
if: matrix.target == 'web' && matrix.os == 'ubuntu-latest' | |
uses: JamesIves/github-pages-deploy-action@v4.5.0 | |
with: | |
branch: gh-pages | |
folder: src/web | |
clean: true |