---
runs:
  using: composite
  steps:
    - name: Cache "Checkout `Mapnik`" & "Build `Mapnik`"
      id: cache-mapnik
      uses: actions/cache@v3
      with:
        path: |
          mapnik-build
          mapnik-src
        key: ${{ matrix.image }}-${{ matrix.compiler }}-mapnik-latest

    - name: Checkout `Mapnik`
      uses: actions/checkout@v4
      with:
        path: mapnik-src
        repository: mapnik/mapnik
        submodules: recursive
      if: steps.cache-mapnik.outputs.cache-hit != 'true'

    - name: Build `Mapnik`
      run: |
        export CMAKE_BUILD_PARALLEL_LEVEL=${BUILD_PARALLEL_LEVEL:-$(nproc)}
        cmake -B mapnik-build -S mapnik-src \
          -DBUILD_DEMO_VIEWER:BOOL=OFF \
          -DBUILD_TESTING:BOOL=OFF \
          -DCMAKE_BUILD_TYPE:STRING=Release \
          -DCMAKE_INSTALL_PREFIX:PATH=/usr
        cmake --build mapnik-build
      shell: bash --noprofile --norc -euxo pipefail {0}
      if: steps.cache-mapnik.outputs.cache-hit != 'true'

    - name: Install `Mapnik`
      run: cmake --install mapnik-build
      shell: bash --noprofile --norc -euxo pipefail {0}
