Improve installation of graphviz #382
This file contains hidden or 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: GH Doxygen | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| DOXYGEN_VERSION: "1.14.0" | |
| CMAKE_VERSION: "4.0.3" | |
| GRAPHVIZ_VERSION: "13.1.1" | |
| jobs: | |
| generate-docs: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| shell: bash | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: "true" | |
| ################################## | |
| # 📦 Cache and Install CMake | |
| ################################## | |
| - name: Cache CMake | |
| id: cache-cmake | |
| uses: actions/cache@v4 | |
| with: | |
| path: cmake-install | |
| key: cmake-cache-${{ env.CMAKE_VERSION }} | |
| - name: Install CMake | |
| if: steps.cache-cmake.outputs.cache-hit != 'true' | |
| run: | | |
| mkdir -p cmake-install | |
| curl -LO https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz | |
| tar -xf cmake-${CMAKE_VERSION}-linux-x86_64.tar.gz --strip-components=1 -C cmake-install | |
| shell: bash | |
| - name: Add CMake to PATH | |
| run: echo "${GITHUB_WORKSPACE}/cmake-install/bin" >> $GITHUB_PATH | |
| ################################## | |
| # 📦 Cache and Install Doxygen | |
| ################################## | |
| - name: Cache Doxygen | |
| id: cache-doxygen | |
| uses: actions/cache@v4 | |
| with: | |
| path: doxygen-${{ env.DOXYGEN_VERSION }} | |
| key: doxygen-cache-${{ env.DOXYGEN_VERSION }} | |
| - name: Install Doxygen from GitHub | |
| if: steps.cache-doxygen.outputs.cache-hit != 'true' | |
| run: | | |
| version_underscore=$(echo "$DOXYGEN_VERSION" | sed 's/\./_/g') | |
| dirname=doxygen-$DOXYGEN_VERSION | |
| filename_tar=$dirname.linux.bin.tar | |
| filename_gz=$filename_tar.gz | |
| url=https://github.com/doxygen/doxygen/releases/download/Release_$version_underscore/$filename_gz | |
| wget $url | |
| gunzip $filename_gz | |
| tar xf $filename_tar | |
| shell: bash | |
| - name: Add Doxygen to PATH | |
| run: echo "${GITHUB_WORKSPACE}/doxygen-${{ env.DOXYGEN_VERSION }}/bin" >> $GITHUB_PATH | |
| ################################## | |
| # 📦 Deps for Graphviz (pangocairo) + cached fonts | |
| ################################## | |
| - name: Cache & install build deps + fonts via APT | |
| uses: awalsh128/cache-apt-pkgs-action@v1 | |
| with: | |
| packages: > | |
| build-essential pkg-config libexpat1-dev libltdl-dev | |
| libcairo2-dev libpango1.0-dev libfontconfig1-dev | |
| libfreetype6-dev libpng-dev libjpeg-dev zlib1g-dev | |
| fontconfig fonts-dejavu-core fonts-liberation gsfonts fonts-urw-base35 | |
| version: 3 | |
| ################################## | |
| # 🧱 Build Graphviz (pangocairo; no gd) from source — cached | |
| ################################## | |
| - name: Cache Graphviz build (pangocairo) | |
| id: cache-graphviz-cairo | |
| uses: actions/cache@v4 | |
| with: | |
| path: graphviz-install | |
| key: ${{ runner.os }}-graphviz-${{ env.GRAPHVIZ_VERSION }}-cairo-nogd | |
| - name: Build & install Graphviz (pangocairo; no gd) | |
| if: steps.cache-graphviz-cairo.outputs.cache-hit != 'true' | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| curl -LO "https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/${GRAPHVIZ_VERSION}/graphviz-${GRAPHVIZ_VERSION}.tar.gz" | |
| tar -xf "graphviz-${GRAPHVIZ_VERSION}.tar.gz" | |
| cd "graphviz-${GRAPHVIZ_VERSION}" | |
| # Build with pangocairo; disable gd so -Tpng uses cairo by default | |
| ./configure --prefix="${GITHUB_WORKSPACE}/graphviz-install" \ | |
| --without-gd \ | |
| --disable-swig --disable-guile --disable-java \ | |
| --disable-lua --disable-perl --disable-php \ | |
| --disable-python --disable-r --disable-ruby | |
| make -j"$(nproc)" | |
| make install | |
| - name: Add Graphviz to PATH & set lib path | |
| shell: bash | |
| run: | | |
| echo "${GITHUB_WORKSPACE}/graphviz-install/bin" >> "$GITHUB_PATH" | |
| echo "LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/graphviz-install/lib:${LD_LIBRARY_PATH:-}" >> "$GITHUB_ENV" | |
| ################################## | |
| # 🖋️ Install fonts (cached) & refresh caches for Graphviz | |
| ################################## | |
| - name: Refresh font caches & Graphviz plugin cache | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| # Ensure system fontconfig is used | |
| unset FONTCONFIG_FILE FONTCONFIG_PATH || true | |
| # Rebuild fontconfig cache and refresh Graphviz plugin cache | |
| fc-cache -f | |
| "${GITHUB_WORKSPACE}/graphviz-install/bin/dot" -c || true | |
| # Smoke test with Helvetica (aliased via fontconfig to Nimbus Sans) | |
| fc-match Helvetica || true | |
| echo 'digraph G { | |
| graph [fontname="Helvetica"]; | |
| node [fontname="Helvetica"]; | |
| edge [fontname="Helvetica"]; | |
| a -> b; label="Helvetica test"; | |
| }' | "${GITHUB_WORKSPACE}/graphviz-install/bin/dot" -Tpng -o /tmp/helvetica.png | |
| ls -lh /tmp/helvetica.png || true | |
| ################################## | |
| # 📚 Generate Doxygen Documentation (force Helvetica; png via cairo) | |
| ################################## | |
| - name: Generate Doxygen Documentation | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p build && cd build | |
| cmake .. \ | |
| -DBUILD_SOURCE=OFF \ | |
| -DDOXYGEN_GENERATE_LATEX=FALSE \ | |
| -DDOXYGEN_DOT_FONTNAME="Helvetica" | |
| # No need to force DOT_EXECUTABLE; it's on PATH now | |
| # PNG will use cairo because Graphviz was built --without-gd | |
| cmake --build . --target doxygen | |
| ################################## | |
| # 🚀 Deploy to GitHub Pages | |
| ################################## | |
| - name: Upload documentation to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs/doxygen/build/html | |
| publish_branch: gh-pages # explicit (default) | |
| keep_files: false # remove anything that isn't in publish_dir | |
| force_orphan: true # recreate gh-pages as a single clean commit | |
| # In the repository settings, go to Actions -> General -> Workflow permissions | |
| # and enable Read and write permissions. | |
| # After the workflow runs successfully, go to Settings -> Pages -> Branch | |
| # select `gh-pages` and click "Save". |