Burr 0.42.0 release prep #34
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #<!-- | |
| # Licensed to the Apache Software Foundation (ASF) under one | |
| # or more contributor license agreements. See the NOTICE file | |
| # distributed with this work for additional information | |
| # regarding copyright ownership. The ASF licenses this file | |
| # to you under the Apache License, Version 2.0 (the | |
| # "License"); you may not use this file except in compliance | |
| # with the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, | |
| # software distributed under the License is distributed on an | |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
| # KIND, either express or implied. See the License for the | |
| # specific language governing permissions and limitations | |
| # under the License. | |
| #--> | |
| name: Build Sphinx Documentation | |
| on: | |
| push: | |
| branches: [ "main", "update_references"] | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/sphinx-docs.yml' | |
| pull_request: | |
| branches: [ "main", "update_references" ] | |
| paths: | |
| - 'docs/**' | |
| - '.github/workflows/sphinx-docs.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: "doc-pages" | |
| cancel-in-progress: true | |
| jobs: | |
| build-docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python 3.12 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| cache: 'pip' | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y graphviz | |
| - name: Upgrade pip and setuptools | |
| run: | | |
| python -m pip install --upgrade --no-cache-dir pip setuptools | |
| - name: Install Sphinx and dependencies | |
| run: | | |
| python -m pip install --upgrade --no-cache-dir sphinx sphinx-rtd-theme sphinx-simplepdf | |
| # python -m pip install --group documentation --upgrade --upgrade-strategy only-if-needed --no-cache-dir | |
| pip install -e ".[documentation]" | |
| - name: Build Sphinx documentation | |
| working-directory: ./docs | |
| run: | | |
| # sphinx-build docs -b dirhtml _build | |
| python -m sphinx -T -W --keep-going -b dirhtml -d _build/doctrees -D language=en . _build/html | |
| - name: Upload HTML artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sphinx-docs-html | |
| path: docs/_build/html/ | |
| retention-days: 5 | |
| - name: Upload PDF artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: sphinx-docs-pdf | |
| path: docs/_build/pdf/ | |
| retention-days: 5 | |
| - name: Deploy documentation | |
| working-directory: ./docs | |
| run: | | |
| # Set target branch based on current branch | |
| if [ "${{ github.ref }}" = "refs/heads/main" ]; then | |
| TARGET_BRANCH="asf-site" | |
| echo "Deploying to production (asf-site) branch" | |
| else | |
| TARGET_BRANCH="asf-staging" | |
| echo "Deploying to staging (asf-staging) branch" | |
| fi | |
| # Configure git | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| # Create a temporary directory | |
| mkdir -p /tmp/gh-pages | |
| # Store current directory | |
| CURRENT_DIR=$(pwd) | |
| ls -lsa $CURRENT_DIR | |
| # Try to clone the repository with the target branch | |
| if ! git clone --branch $TARGET_BRANCH --single-branch \ | |
| https://github.com/${{ github.repository }}.git /tmp/gh-pages 2>/dev/null; then | |
| # If branch doesn't exist, initialize a new repository and create the branch | |
| echo "Branch $TARGET_BRANCH doesn't exist. Creating it..." | |
| rm -rf /tmp/gh-pages | |
| mkdir -p /tmp/gh-pages | |
| cd /tmp/gh-pages | |
| git init | |
| git config --local init.defaultBranch $TARGET_BRANCH | |
| git checkout -b $TARGET_BRANCH | |
| git remote add origin https://github.com/${{ github.repository }}.git | |
| cd "$CURRENT_DIR" | |
| else | |
| echo "CD'ing into $CURRENT_DIR" | |
| cd "$CURRENT_DIR" | |
| fi | |
| # Remove existing content directory if it exists | |
| rm -rf /tmp/gh-pages/content | |
| # # Ensure build directories exist | |
| # mkdir -p "$CURRENT_DIR/_build/html" | |
| # Copy the built HTML documentation to the content directory | |
| mkdir -p /tmp/gh-pages/content | |
| cp -r "$CURRENT_DIR/_build/html/"* /tmp/gh-pages/content/ 2>/dev/null || echo "No HTML files to copy" | |
| # Add, commit and push the changes | |
| cd /tmp/gh-pages | |
| git status | |
| ls -lhsa content | |
| # Create a README if it doesn't exist | |
| if [ ! -f README.md ]; then | |
| echo "# Documentation for $TARGET_BRANCH" > README.md | |
| echo "This branch contains the built documentation." >> README.md | |
| fi | |
| git add -A | |
| git status | |
| # Check if there are changes to commit (including untracked files) | |
| if [ -n "$(git status --porcelain)" ]; then | |
| git commit -m "Deploy documentation from ${{ github.sha }}" | |
| git push https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git $TARGET_BRANCH | |
| echo "Changes pushed to $TARGET_BRANCH branch" | |
| else | |
| echo "No changes to deploy" | |
| fi |