OpenJij/OpenJij

View on GitHub
.github/workflows/buid-doc.yml

Summary

Maintainability
Test Coverage
name: Build Documentation

on:
  workflow_dispatch:
  release:
    types: [published]
  push:
    branches: 
      - main

concurrency:
      group: Buid-Documentation
      cancel-in-progress: false

env:
  Python_Version: '3.10'

jobs:
  build_docs:
    name: Build Documentation 
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        name: Install Python
        with:
          python-version: ${{env.Python_Version}}
      - name: Python Cache Key
        shell: bash
        run: |
          echo $(which python) > /tmp/python_version.txt
      - name: Get pip cache dir
        shell: bash
        id: pip-cache
        run: |
          echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
      - name: Pip-Tools 
        shell: bash
        run: |
          python -m pip install pip-tools 
          pip-compile
          pip-compile dev-requirements.in
      - name: pip cache
        uses: actions/cache@v4
        with:
           path: ${{ steps.pip-cache.outputs.dir }}
           key: ${{ runner.os }}-pip-${{ hashFiles('/tmp/python_version.txt') }}
           restore-keys: |
              ${{ runner.os }}-pip-
      - name: Update
        run: | 
         pip install --upgrade pip wheel setuptools build cmake ninja 
      - name: Install Dependencies
        shell: bash
        run: |
          set -eux
          pip-sync requirements.txt dev-requirements.txt
      - name: Install Dep
        run: | 
         pip install typing-extensions
         sudo apt-get install -y libeigen3-dev lcov graphviz mscgen dia pdf2svg astyle
         sudo apt-get install -y doxygen doxygen-doxyparse fonts-liberation python3-breathe
      - name: Prepare 
        shell: bash
        run: mkdir build
      - name: CMake Configure
        shell: bash
        run: >
          cmake 
          -DBUILD_DOCS=ON
          -G Ninja
          -S .
          -B build
      - name: CMake Build
        shell: bash
        run: >
          cmake  
          --build build
          --parallel
          --verbose
          --target cxxjij_header_only_docs
      - name: Copy Doc
        shell: bash
        run: |
          set -eux
          cp -r ./build/html/* ./public/
      - name: du -a 
        shell: bash
        if: always()
        run: |
          du -a
      - name: Prepare tag
        id: prepare_tag
        if: startsWith(github.ref, 'refs/tags/')
        run: |
          TAG_NAME="${GITHUB_REF##refs/tags/}"
          echo "tag_name=${TAG_NAME}" >> $GITHUB_OUTPUT
          echo "deploy_tag_name=deploy-${TAG_NAME}" >> $GITHUB_OUTPUT
      - name: Deploy
        #if: ${{github.event_name == 'release'}}
        uses: peaceiris/actions-gh-pages@v3
        with:
         personal_token: ${{ secrets.OPENJIJ_WEB }}
         keep_files: true
         allow_empty_commit: true
         publish_dir: ./public
         publish_branch: main
         external_repository: OpenJij/OpenJij-Reference-Page
         destination_dir: www
         user_name: 'github-actions[bot]'
         user_email: 'github-actions[bot]@users.noreply.github.com'
         commit_message: ${{ github.event.head_commit.message }}
         full_commit_message: ${{ github.event.head_commit.message }}
         tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
         tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'