Files
lvgl/.github/workflows/compile_docs.yml
T

206 lines
7.0 KiB
YAML

name: Build Docs
on:
workflow_dispatch: # allow manual triggering
inputs:
deploy:
description: 'Deploy after build'
default: 'false'
type: choice
options:
- 'false'
- 'true'
pull_request:
paths:
- 'docs/**'
- 'src/**'
- 'examples/**'
- 'demos/**'
- 'configs/ci/docs/**'
- 'scripts/build_html_examples.sh'
- 'scripts/find_version.sh'
- 'lv_conf_template.h'
- 'lv_version.h'
- 'lvgl.h'
- '.github/workflows/compile_docs.yml'
push:
branches:
- master
- 'release/*'
paths:
- 'docs/**'
- 'src/**'
- 'examples/**'
- 'demos/**'
- 'configs/ci/docs/**'
- 'scripts/build_html_examples.sh'
- 'scripts/find_version.sh'
- 'lv_conf_template.h'
- 'lv_version.h'
- 'lvgl.h'
- '.github/workflows/compile_docs.yml'
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency
# Ensure that only one commit will be running tests at a time on each PR
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
EM_VERSION: 2.0.4
EM_CACHE_FOLDER: 'emsdk-cache'
jobs:
build-and-deploy:
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v6
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Emscripten cache
id: cache-system-libraries
uses: actions/cache@v5
with:
path: ${{env.EM_CACHE_FOLDER}}
key: ${{env.EM_VERSION}}-${{ runner.os }}
- uses: mymindstorm/setup-emsdk@v16
with:
version: ${{env.EM_VERSION}}
actions-cache-folder: ${{env.EM_CACHE_FOLDER}}
- name: ccache
uses: hendrikmuhs/ccache-action@v1
- name: Build examples (with cache)
run: |
# Grab the current name in case the LVGL folder is not called lvgl
# as it could be the case if this is running from a fork
LVGL_FOLDER=$(pwd)
# Move to the parent folder to fetch emscripten port.
cd ..
./lvgl/scripts/build_html_examples.sh --symlink $LVGL_FOLDER
- name: Install Doxygen
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends doxygen
# Parses the source code and generates XML files from the documentation
- name: Generate Doxygen XML
run: |
cd docs
doxygen
# Tool used to convert Doxygen XML to .mdx API pages
- name: Install doxymark
run: |
npm install github:mutahharmkhan/doxymark#multi-root-prefix
# Generate Documentation API pages
- name: Generate API pages
run: |
npx doxymark \
--input docs/doxygen/xml \
--output docs/src \
--index docs/src/api-index.json \
--preset fumadocs \
--auto-group \
--root api=./include/lvgl \
--root api-private=./src \
--source-url-for api=https://github.com/lvgl/lvgl/tree/${{ github.sha }}/include/lvgl \
--source-url-for api-private=https://github.com/lvgl/lvgl/tree/${{ github.sha }}/src \
--root-title api=API \
--root-title 'api-private=API Private' \
--drop-empty-files
rm -rf docs/doxygen
- name: Install Example Documentation
run: npm i @lvgl/examples-generator
- name: Check Example Documentation
run: |
npx -p @lvgl/examples-generator lvgl-examples-check-about --src examples
npx -p @lvgl/examples-generator lvgl-examples-check-examples --src examples
- name: Generate Example Documentation
run: |
npx -p @lvgl/examples-generator lvgl-examples-gen \
--src examples \
--out docs/src/examples
- name: Install mdx linter
run: npm i @lvgl/mdx-lint
- name: Run mdx linter
run: |
npx @lvgl/mdx-lint "docs/**/*.{md,mdx}" \
--fail-on-warning \
--reporter github
- name: Convert xml files to md
run: |
mkdir -p /tmp/xml
python3 docs/xml_to_md.py examples /tmp/xml --source-base https://github.com/lvgl/lvgl/blob/${{ github.sha }}/examples
- name: Retrieve version
id: version
run: |
echo "VERSION_NAME=$(scripts/find_version.sh)" >> "$GITHUB_OUTPUT"
- name: Deploy Specific Version
if: >
startsWith(github.ref, 'refs/heads/release/') &&
(github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true'))
run: |
git clone https://lvgl-bot:${{ secrets.LVGL_BOT_TOKEN }}@github.com/lvgl/open-docs.git /tmp/open-docs
rm -rf /tmp/open-docs/${{ steps.version.outputs.VERSION_NAME }}
rm -rf /tmp/open-docs/xml/${{ steps.version.outputs.VERSION_NAME }}
mkdir -p /tmp/open-docs/${{ steps.version.outputs.VERSION_NAME }}
mkdir -p /tmp/open-docs/xml/${{ steps.version.outputs.VERSION_NAME }}
cp -r docs/. /tmp/open-docs/${{ steps.version.outputs.VERSION_NAME }}/
cp -r /tmp/xml/. /tmp/open-docs/xml/${{ steps.version.outputs.VERSION_NAME }}/
cd /tmp/open-docs
git config user.name lvgl-bot
git config user.email lvgl-bot@users.noreply.github.com
git add .
git diff --cached --quiet || git commit -m "Deploy ${{ steps.version.outputs.VERSION_NAME }} ${{ github.sha }}"
git push
- name: Deploy Latest
if: >
github.ref == 'refs/heads/master' &&
(github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.deploy == 'true'))
run: |
git clone https://lvgl-bot:${{ secrets.LVGL_BOT_TOKEN }}@github.com/lvgl/open-docs.git /tmp/open-docs-latest
rm -rf /tmp/open-docs-latest/latest
rm -rf /tmp/open-docs-latest/${{ steps.version.outputs.VERSION_NAME }}
rm -rf /tmp/open-docs-latest/xml/latest
rm -rf /tmp/open-docs-latest/xml/${{ steps.version.outputs.VERSION_NAME }}
mkdir -p /tmp/open-docs-latest/latest
mkdir -p /tmp/open-docs-latest/${{ steps.version.outputs.VERSION_NAME }}
mkdir -p /tmp/open-docs-latest/xml/latest
mkdir -p /tmp/open-docs-latest/xml/${{ steps.version.outputs.VERSION_NAME }}
cp -r docs/. /tmp/open-docs-latest/latest/
cp -r docs/. /tmp/open-docs-latest/${{ steps.version.outputs.VERSION_NAME }}/
cp -r /tmp/xml/. /tmp/open-docs-latest/xml/latest
cp -r /tmp/xml/. /tmp/open-docs-latest/xml/${{ steps.version.outputs.VERSION_NAME }}/
cd /tmp/open-docs-latest
git config user.name lvgl-bot
git config user.email lvgl-bot@users.noreply.github.com
git add .
git diff --cached --quiet || git commit -m "Deploy ${{ steps.version.outputs.VERSION_NAME }} and latest from commit ${{ github.sha }}"
git push