|
| 1 | +name: documentation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - "*" |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*" |
| 10 | + |
| 11 | +# Grants the runner permission to push to the repository (protect your main branch via Settings!) |
| 12 | +permissions: |
| 13 | + contents: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build-and-deploy: |
| 17 | + name: Build & Deploy Documentation |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Check out repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + submodules: recursive |
| 26 | + |
| 27 | + - name: Set up Python |
| 28 | + uses: actions/setup-python@v5 |
| 29 | + with: |
| 30 | + python-version: "3.14" |
| 31 | + |
| 32 | + - name: Install system dependencies |
| 33 | + run: sudo apt-get update && sudo apt-get install doxygen -y |
| 34 | + |
| 35 | + - name: Install Python dependencies (uv) |
| 36 | + run: | |
| 37 | + pip install uv |
| 38 | + uv sync |
| 39 | +
|
| 40 | + - name: Validate internal project versions |
| 41 | + # Runs your script to ensure CMake, Doxygen, and Bazel versions are identical |
| 42 | + run: | |
| 43 | + VERSION=$(uv run python scripts/check_version.py) |
| 44 | + echo "project version = $VERSION" |
| 45 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - name: Validate Git Tag (Deploy Only) |
| 48 | + if: github.event_name == 'push' |
| 49 | + run: | |
| 50 | + VERSION_TAG="${GITHUB_REF_NAME}" |
| 51 | + echo "git version tag = $VERSION_TAG" |
| 52 | + if [[ "$VERSION_TAG" != "v$VERSION" ]]; then |
| 53 | + echo "Error: Tag mismatch: git version tag = $VERSION_TAG, project version: v$VERSION" |
| 54 | + exit 1 |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Generate internal documentation assets |
| 58 | + run: | |
| 59 | + doxygen Doxyfile |
| 60 | + uv run python docs/scripts/gen_concept_docs.py --config docs/config/concepts.json --xml documentation/xml --out docs/cpp-gl |
| 61 | +
|
| 62 | + - name: Build Docs (PR Validation Only) |
| 63 | + if: github.event_name == 'pull_request' |
| 64 | + run: uv run mkdocs build --strict |
| 65 | + |
| 66 | + - name: Configure Git (Deploy Only) |
| 67 | + if: github.event_name == 'push' |
| 68 | + run: | |
| 69 | + git config --local user.name "github-actions[bot]" |
| 70 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 71 | +
|
| 72 | + - name: Determine if Latest Tag (Deploy Only) |
| 73 | + if: github.event_name == 'push' |
| 74 | + run: | |
| 75 | + CURRENT_VERSION="v${VERSION}" |
| 76 | + git fetch --tags --force |
| 77 | + # Sorts tags by version number to find the absolute latest |
| 78 | + ALL_TAGS=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V) |
| 79 | + LATEST_TAG=$(echo "$ALL_TAGS" | tail -n 1) |
| 80 | +
|
| 81 | + if [ "$CURRENT_VERSION" = "$LATEST_TAG" ]; then |
| 82 | + echo "DEPLOY_LATEST=true" >> $GITHUB_ENV |
| 83 | + echo "Current tag is the latest. Will deploy and update 'latest' alias." |
| 84 | + else |
| 85 | + echo "DEPLOY_LATEST=false" >> $GITHUB_ENV |
| 86 | + echo "Current tag is NOT the latest. Will deploy to 'v${VERSION}' only." |
| 87 | + fi |
| 88 | +
|
| 89 | + - name: Deploy with mike (Latest) |
| 90 | + if: github.event_name == 'push' && env.DEPLOY_LATEST == 'true' |
| 91 | + run: | |
| 92 | + # Deploys to the v-prefixed folder and tags it as 'latest' |
| 93 | + uv run mike deploy --push --update-aliases "v${VERSION}" latest |
| 94 | + # Sets the root redirect to point to the 'latest' alias |
| 95 | + uv run mike set-default --push latest |
| 96 | +
|
| 97 | + - name: Deploy with mike (Older Version) |
| 98 | + if: github.event_name == 'push' && env.DEPLOY_LATEST == 'false' |
| 99 | + run: | |
| 100 | + uv run mike deploy --push "v${VERSION}" |
0 commit comments