diff --git a/.github/workflows/docs-pages.yml b/.github/workflows/docs-pages.yml new file mode 100644 index 000000000..307336ed1 --- /dev/null +++ b/.github/workflows/docs-pages.yml @@ -0,0 +1,93 @@ +name: Documentation Pages + +on: + push: + branches: [master] + paths: + - ".github/workflows/docs-pages.yml" + - "CMakeLists.txt" + - "README.md" + - "docs/**" + - "examples/**" + - "include/**" + - "scripts/**" + - "src/**" + pull_request: + paths: + - ".github/workflows/docs-pages.yml" + - "CMakeLists.txt" + - "README.md" + - "docs/**" + - "examples/**" + - "include/**" + - "scripts/**" + - "src/**" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: pages-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: "3.x" + + - name: Install documentation dependencies + run: | + sudo apt-get update + sudo apt-get install -y cmake doxygen graphviz + python -m pip install libclang pyyaml + + - name: Build InfiniRT + run: | + git clone --depth 1 "${INFINI_RT_GIT_URL:-https://github.com/InfiniTensor/InfiniRT.git}" /tmp/infini-rt-src + cmake -S /tmp/infini-rt-src -B /tmp/infini-rt-build \ + -DWITH_CPU=ON \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_INSTALL_PREFIX=/tmp/infini-rt-prefix + cmake --build /tmp/infini-rt-build -j"$(nproc)" + cmake --install /tmp/infini-rt-build + + - name: Configure documentation build + run: | + cmake -S . -B build \ + -DINFINI_RT_ROOT=/tmp/infini-rt-prefix \ + -DWITH_CPU=ON \ + -DINFINI_OPS_BUILD_DOCS=ON + + - name: Build documentation + run: cmake --build build --target infiniops_docs + + - name: Validate generated site + run: | + test -f build/docs/reference/html/index.html + grep -q "InfiniOps" build/docs/reference/html/index.html + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v3 + with: + path: build/docs/reference/html + + deploy: + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + needs: build + runs-on: ubuntu-latest + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/docs/README.md b/docs/README.md index 5877a9d50..10fe28f49 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,6 +35,6 @@ Start with these pages: - [Compatibility](compatibility.md): public API boundary, generated files, and internal implementation headers. -The API reference can be generated locally with Doxygen. Publishing the -generated HTML is intentionally handled separately from the local documentation -target. +The API reference can be generated locally with Doxygen. The Documentation Pages +workflow validates that generated HTML for pull requests and publishes `master` +builds through GitHub Pages. diff --git a/docs/api/reference.md b/docs/api/reference.md index ae0d5efe4..5ea4ecf7b 100644 --- a/docs/api/reference.md +++ b/docs/api/reference.md @@ -68,5 +68,7 @@ Use [Compatibility](../compatibility.md) for the supported API boundary. ## Publishing -This target only generates local HTML. GitHub Pages validation and publishing -should be added in a dedicated CI PR. +The Documentation Pages workflow builds the same `infiniops_docs` target for +pull requests and uploads the generated HTML as a Pages artifact. Pushes to +`master` deploy the artifact through GitHub Pages when the repository Pages +source is configured for GitHub Actions. diff --git a/docs/build.md b/docs/build.md index 2ca96fbed..470edc07e 100644 --- a/docs/build.md +++ b/docs/build.md @@ -119,4 +119,7 @@ cmake --build build --target infiniops_docs The generated HTML is written to `build/docs/reference/html`. +The Documentation Pages workflow uses the same target to validate pull requests +and publish `master` builds through GitHub Pages. + See [API Reference](api/reference.md) for reference scope and preview commands.