| name: CMake / Emscripten |
| |
| on: |
| push: |
| branches: |
| - '**' # only run on branches |
| pull_request: |
| release: |
| types: [published] |
| |
| env: |
| # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) |
| BUILD_TYPE: Release |
| EM_VERSION: 2.0.18 |
| EM_CACHE_FOLDER: 'emsdk-cache' |
| |
| jobs: |
| build: |
| runs-on: ubuntu-22.04 |
| |
| steps: |
| - uses: actions/checkout@v4 |
| |
| - name: Checkout Examples |
| uses: actions/checkout@v4 |
| with: |
| repository: 32blit/32blit-examples |
| path: 32blit-examples |
| |
| - name: Install deps |
| run: | |
| sudo apt update && sudo apt install doxygen graphviz pipx |
| pipx install 32blit |
| |
| - name: Setup cache |
| id: cache-system-libraries |
| uses: actions/cache@v4 |
| with: |
| path: ${{env.EM_CACHE_FOLDER}} |
| key: ${{env.EM_VERSION}}-${{runner.os}} |
| |
| - name: Setup Emscripten |
| uses: mymindstorm/setup-emsdk@v14 |
| with: |
| version: ${{env.EM_VERSION}} |
| actions-cache-folder: ${{env.EM_CACHE_FOLDER}} |
| |
| - name: Create Build Environment |
| run: cmake -E make_directory ${{runner.workspace}}/build |
| |
| - name: Set Tag Variable |
| if: github.event_name == 'release' |
| shell: bash |
| run: echo "TRAVIS_TAG=${{github.event.release.tag_name}}" >> $GITHUB_ENV |
| |
| - name: Configure CMake |
| shell: bash |
| working-directory: ${{runner.workspace}}/build |
| run: emcmake cmake $GITHUB_WORKSPACE/32blit-examples -D32BLIT_DIR=$GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS_RELEASE="-O2 -DNDEBUG" |
| |
| # Problem matching |
| - uses: ammaraskar/gcc-problem-matcher@master |
| |
| - name: Build |
| working-directory: ${{runner.workspace}}/build |
| shell: bash |
| run: | |
| embuilder.py build sdl2 sdl2-image-jpg sdl2-net |
| cmake --build . --config $BUILD_TYPE -j 2 |
| |
| - name: Prepare Site |
| run: | |
| mkdir -p site/examples |
| cp ../build/*/*.{js,wasm} site/examples |
| |
| - name: Upload Artifact |
| uses: actions/upload-artifact@v4 |
| with: |
| name: ${{github.event.repository.name}}-${{github.sha}}-web |
| path: site |
| |
| # build the docs |
| - name: Build Docs |
| if: github.ref == 'refs/heads/master' # github.event_name == 'release' |
| run: | |
| cd 32blit && doxygen doxygen.conf && cd .. |
| cp -r 32blit/documentation/html/* site |
| |
| - name: Deploy to GitHub Pages |
| if: github.ref == 'refs/heads/master' # github.event_name == 'release' |
| uses: crazy-max/ghaction-github-pages@v4 |
| with: |
| target_branch: gh-pages |
| build_dir: site |
| env: |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |