|
| 1 | +# |
| 2 | +# Licensed under the Apache License v2.0 with LLVM Exceptions. |
| 3 | +# See https://llvm.org/LICENSE.txt for license information. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | +# |
| 6 | +# Copyright (c) 2026 Alan de Freitas (alandefreitas@gmail.com) |
| 7 | +# |
| 8 | +# Official repository: https://github.com/cppalliance/mrdocs |
| 9 | +# |
| 10 | +# Per-OS validation that the docs/website/Antora-UI pipelines build |
| 11 | +# cleanly with the installed mrdocs binary. Scope-gated: runs when |
| 12 | +# source, docs, build, or third-party files changed (i.e. anything |
| 13 | +# that can influence rendered documentation). Skipped on tooling / |
| 14 | +# ci / toolchain-only PRs. |
| 15 | + |
| 16 | +name: Documentation |
| 17 | + |
| 18 | +on: |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + submatrix: |
| 22 | + description: 'JSON-encoded releases submatrix from cpp-matrix' |
| 23 | + type: string |
| 24 | + required: true |
| 25 | + use-develop-binaries: |
| 26 | + description: 'true to fetch packages from develop-release instead of this run' |
| 27 | + type: boolean |
| 28 | + default: false |
| 29 | + |
| 30 | +jobs: |
| 31 | + documentation: |
| 32 | + strategy: |
| 33 | + fail-fast: false |
| 34 | + matrix: |
| 35 | + include: ${{ fromJSON(inputs.submatrix) }} |
| 36 | + |
| 37 | + defaults: |
| 38 | + run: |
| 39 | + shell: bash |
| 40 | + |
| 41 | + name: ${{ matrix.os }} |
| 42 | + runs-on: ${{ matrix.runs-on }} |
| 43 | + container: ${{ matrix.container }} |
| 44 | + permissions: |
| 45 | + contents: read |
| 46 | + steps: |
| 47 | + - name: Container Bootstrap |
| 48 | + uses: alandefreitas/cpp-actions/container-bootstrap@v1.9.4 |
| 49 | + |
| 50 | + - name: Install packages |
| 51 | + uses: alandefreitas/cpp-actions/package-install@v1.9.4 |
| 52 | + with: |
| 53 | + apt-get: build-essential asciidoctor cmake bzip2 git rsync |
| 54 | + |
| 55 | + - name: Clone MrDocs |
| 56 | + uses: actions/checkout@v4 |
| 57 | + with: |
| 58 | + fetch-depth: 1 |
| 59 | + |
| 60 | + - name: Install Node.js |
| 61 | + uses: actions/setup-node@v4 |
| 62 | + with: |
| 63 | + node-version: '20' |
| 64 | + |
| 65 | + - name: Setup C++ |
| 66 | + uses: alandefreitas/cpp-actions/setup-cpp@v1.9.4 |
| 67 | + id: setup-cpp |
| 68 | + with: |
| 69 | + compiler: ${{ matrix.compiler }} |
| 70 | + version: ${{ matrix.version }} |
| 71 | + |
| 72 | + # Same dual-source pattern as ci-releases.yml: fresh-build artifact |
| 73 | + # when we built this run, develop-release fallback otherwise. |
| 74 | + - name: Download MrDocs package (fresh build) |
| 75 | + if: ${{ !inputs.use-develop-binaries }} |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + name: ${{ matrix.mrdocs-release-package-artifact }} |
| 79 | + path: packages |
| 80 | + |
| 81 | + - name: Download MrDocs package (develop-release fallback) |
| 82 | + if: ${{ inputs.use-develop-binaries }} |
| 83 | + env: |
| 84 | + GH_TOKEN: ${{ github.token }} |
| 85 | + run: | |
| 86 | + set -euo pipefail |
| 87 | + mkdir -p packages |
| 88 | + case "${{ runner.os }}" in |
| 89 | + Linux) pattern='*Linux*' ;; |
| 90 | + Windows) pattern='*Windows*' ;; |
| 91 | + macOS) pattern='*Darwin*' ;; |
| 92 | + *) echo "::error::unknown runner.os: ${{ runner.os }}"; exit 1 ;; |
| 93 | + esac |
| 94 | + gh release download develop-release --pattern "$pattern" -D packages |
| 95 | +
|
| 96 | + - name: Install MrDocs from Package |
| 97 | + run: .github/scripts/install-mrdocs-package.sh |
| 98 | + |
| 99 | + - name: Generate Landing Page |
| 100 | + working-directory: docs/website |
| 101 | + run: | |
| 102 | + npm ci |
| 103 | + node render.js |
| 104 | + mkdir -p ../../build/website |
| 105 | + cp index.html ../../build/website/index.html |
| 106 | + cp robots.txt ../../build/website/robots.txt |
| 107 | + cp styles.css ../../build/website/styles.css |
| 108 | + cp -r assets ../../build/website/assets |
| 109 | +
|
| 110 | + - name: Generate Antora UI |
| 111 | + working-directory: docs/ui |
| 112 | + run: | |
| 113 | + GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 114 | + export GH_TOKEN |
| 115 | + npm ci |
| 116 | + npx gulp lint |
| 117 | + npx gulp |
| 118 | +
|
| 119 | + - name: Generate Local Documentation |
| 120 | + working-directory: docs |
| 121 | + run: | |
| 122 | + GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 123 | + export GH_TOKEN |
| 124 | + set -x |
| 125 | + npm ci |
| 126 | + npx antora antora-playbook.yml --attribute branchesarray=HEAD --stacktrace --log-level=debug |
| 127 | + mkdir -p ../build/docs-local |
| 128 | + cp -vr build/site/* ../build/docs-local |
| 129 | +
|
| 130 | + - name: Upload Website as Artifact |
| 131 | + uses: actions/upload-artifact@v4 |
| 132 | + with: |
| 133 | + name: Website ${{ runner.os }} |
| 134 | + path: build/website |
| 135 | + retention-days: 30 |
0 commit comments