Skip to content

Publish Website

Publish Website #1

name: Publish Website
on:
workflow_call:
inputs:
new_version:
required: false
type: string
run_tutorials:
required: false
type: boolean
default: false
dry_run:
required: false
type: boolean
default: false
workflow_dispatch:
run_tutorials:
required: true
type: boolean
default: false
dry_run:
required: true
type: boolean
default: false
jobs:
build-website:
runs-on: ubuntu-latest
env:
# `uv pip ...` requires venv by default. This skips that requirement.
UV_SYSTEM_PYTHON: 1
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: 'gh-pages' # release branch
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Sync release branch with main
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git merge origin/main
# To avoid a large number of commits we don't push this sync commit to github until a new release.
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.14"
- if: ${{ !inputs.new_version }}
name: Install latest GPyTorch and Linear Operator
run: |
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
uv pip install git+https://github.com/cornellius-gp/gpytorch.git
- name: Install dependencies
run: |
uv pip install ."[dev, tutorials]"
- if: ${{ inputs.new_version }}
name: Delete existing similar versions from Docusaurus
run: |
# Delete existing versions for same Major and Minor version numbers.
# We do this to keep only the latest patch for a given major/minor version.
MAJOR_MINOR_VERSION=$(cut -d '.' -f 1-2 <<< ${{ inputs.new_version }}) # remove patch number
MAJOR_MINOR_VERSION=${MAJOR_MINOR_VERSION#v} # remove optional "v" prefix
for dir in website/versioned_docs/version-$MAJOR_MINOR_VERSION.*; do
if [ -d "$dir" ]; then
OLD_VERSION=$(basename "$dir" | sed 's/^version-//') # remove "version-" prefix from the directory name
echo "Deleting older version $OLD_VERSION with the same major and minor version numbers as $NEW_VERSION"
# Delete version from the three locations Docusaurus uses:
# - versioned_docs/version-X.Y.Z/
# - versioned_sidebars/version-X.Y.Z-sidebars.json
# - versions.json
# https://docusaurus.io/docs/versioning#deleting-an-existing-version
rm -rf "$dir"
rm "website/versioned_sidebars/version-$OLD_VERSION-sidebars.json"
sed -i "/\"$OLD_VERSION\"/d" website/versions.json
fi
done
- if: ${{ inputs.new_version && !inputs.dry_run }}
name: Create new docusaurus version
run: |
python3 scripts/convert_ipynb_to_mdx.py --clean
cd website
yarn
# Check if this version already exists in versions.json
VERSION_TAG="${{ inputs.new_version }}"
VERSION_TAG="${VERSION_TAG#v}" # Remove optional "v" prefix for comparison
if [ -f versions.json ] && grep -q "\"$VERSION_TAG\"" versions.json; then
echo "Version $VERSION_TAG already exists in versions.json, skipping versioning step"
else
yarn docusaurus docs:version ${{ inputs.new_version }}
git add versioned_docs/ versioned_sidebars/ versions.json
git commit -m "Create version ${{ inputs.new_version }} of site in Docusaurus"
git push --force origin HEAD:gh-pages
fi
- name: Build website
run: |
bash scripts/build_docs.sh -b
- name: Upload website build as artifact
id: deployment
uses: actions/upload-pages-artifact@v3
with:
path: website/build/
deploy-website:
if: ${{ !inputs.dry_run }}
needs: build-website
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4