flint3-sys 3.5.1

Rust bindings to the FLINT C library
Documentation
name: Documentation

on:
  pull_request:
    paths:
      - 'doc/**'
      - '.github/workflows/docs.yml'
  push:
    paths:
      - 'doc/**'
      - '.github/workflows/docs.yml'

concurrency:
  # Group by workflow and ref, and to limit to 1 concurrent job except for main
  group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/main' || github.run_number }}
  # Cancel intermediate builds for pull requests
  cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
  #############################################################################
  # build documentation
  #############################################################################
  build-doc:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2

      - name: "Setup"
        run: |
          sudo apt-get update
          sudo apt-get install -y python3-sphinx
          sphinx-build --version

      - name: "Build documentation"
        run: |
          cd doc
          make html SPHINXOPTS="-W -j auto"

      - name: "Setup LaTeX"
        if: github.repository == 'flintlib/flint' && github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: |
          # See https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.latex.LaTeXBuilder
          sudo apt-get install -y texlive-latex-recommended texlive-fonts-recommended texlive-fonts-extra tex-gyre texlive-latex-extra latexmk

      - name: "Build PDF documentation"
        if: github.repository == 'flintlib/flint' && github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: |
          cd doc
          make latexpdf SPHINXOPTS="-W -j auto"

      - name: "Create a tarball of the documentation"
        if: github.repository == 'flintlib/flint' && github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: |
          cd doc/build
          mv html doc
          cp latex/flint.pdf doc
          tar -czvf doc.tar.gz doc

      - name: "Setup SSH key"
        if: github.repository == 'flintlib/flint' && github.event_name == 'push' && github.ref == 'refs/heads/main'
        uses: shimataro/ssh-key-action@v2.7.0
        with:
          key: ${{ secrets.SSH_KEY }}
          name: id_ed25519
          known_hosts: ${{ secrets.KNOWN_HOSTS }}

      - name: "Push documentation to server"
        if: github.repository == 'flintlib/flint' && github.event_name == 'push' && github.ref == 'refs/heads/main'
        run: |
          cd doc/build
          ssh -t wbhart@opal6.opalstack.com 'mkdir ~/tmp'
          scp doc.tar.gz wbhart@opal6.opalstack.com:~/tmp
          ssh -t wbhart@opal6.opalstack.com 'cd ~/tmp && tar -xf doc.tar.gz && rm -rf ~/apps/flintlib_org/doc && mv doc ~/apps/flintlib_org && cd ~ && rm -rf ~/tmp'