|
| 1 | +name: Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - "*" |
| 7 | + push: |
| 8 | + tags: |
| 9 | + - "v*" |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-deploy: |
| 16 | + name: Build & Deploy Documentation |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Check out repository |
| 21 | + uses: actions/checkout@v4 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + submodules: recursive |
| 25 | + |
| 26 | + - name: Set up Python |
| 27 | + uses: actions/setup-python@v5 |
| 28 | + with: |
| 29 | + python-version: "3.14" |
| 30 | + |
| 31 | + - name: Install system dependencies |
| 32 | + run: sudo apt-get update && sudo apt-get install doxygen -y |
| 33 | + |
| 34 | + - name: Install Python dependencies (uv) |
| 35 | + run: | |
| 36 | + pip install uv |
| 37 | + uv sync |
| 38 | +
|
| 39 | + - name: Validate Internal Project Versions |
| 40 | + run: | |
| 41 | + VERSION=$(uv run python scripts/check_version.py) |
| 42 | + echo "project version = $VERSION" |
| 43 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 44 | +
|
| 45 | + - name: Validate Git Tag (Deploy Only) |
| 46 | + if: github.event_name == 'push' |
| 47 | + run: | |
| 48 | + VERSION_TAG="${GITHUB_REF_NAME}" |
| 49 | + echo "git version tag = $VERSION_TAG" |
| 50 | + if [[ "$VERSION_TAG" != "v$VERSION" ]]; then |
| 51 | + echo "Error: Tag mismatch: git version tag = $VERSION_TAG, project version: v$VERSION" |
| 52 | + exit 1 |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Build Docs (PR Validation Only) |
| 56 | + if: github.event_name == 'pull_request' |
| 57 | + run: make build-docs |
| 58 | + |
| 59 | + # See: https://api.github.com/users/github-actions%5Bbot%5D |
| 60 | + - name: Configure Git (Deploy Only) |
| 61 | + if: github.event_name == 'push' |
| 62 | + run: | |
| 63 | + git config --local user.name "github-actions[bot]" |
| 64 | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 65 | +
|
| 66 | + - name: Determine if Latest Tag (Deploy Only) |
| 67 | + if: github.event_name == 'push' |
| 68 | + run: | |
| 69 | + CURRENT_VERSION="v${VERSION}" |
| 70 | + git fetch --tags --force |
| 71 | + ALL_TAGS=$(git tag | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sort -V) |
| 72 | + LATEST_TAG=$(echo "$ALL_TAGS" | tail -n 1) |
| 73 | +
|
| 74 | + if [ "$CURRENT_VERSION" = "$LATEST_TAG" ]; then |
| 75 | + echo "DEPLOY_LATEST=true" >> $GITHUB_ENV |
| 76 | + else |
| 77 | + echo "DEPLOY_LATEST=false" >> $GITHUB_ENV |
| 78 | + fi |
| 79 | +
|
| 80 | + - name: Deploy with mike (Latest) |
| 81 | + if: github.event_name == 'push' && env.DEPLOY_LATEST == 'true' |
| 82 | + run: | |
| 83 | + make docs TAGS="--push --update-aliases v${VERSION} latest" |
| 84 | + uv run mike set-default --push latest |
| 85 | +
|
| 86 | + - name: Deploy with mike (Older Version) |
| 87 | + if: github.event_name == 'push' && env.DEPLOY_LATEST == 'false' |
| 88 | + run: make docs TAGS="--push v${VERSION}" |
0 commit comments