From e8d7b608baade68bdddf4ecb9460af6074c55a4d Mon Sep 17 00:00:00 2001 From: Brent Yi Date: Fri, 24 May 2024 14:24:53 -0700 Subject: [PATCH] Separate `latest/` and `versions/` subdirectories for docs --- .github/workflows/docs.yml | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 7c5f5919a..7b569501e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,7 +13,7 @@ jobs: docs: runs-on: ubuntu-latest steps: - # Check out source + # Check out source. - uses: actions/checkout@v2 - name: Set up Python @@ -21,7 +21,7 @@ jobs: with: python-version: "3.10" - # Build documentation + # Build documentation. - name: Building documentation run: | pip install uv @@ -30,11 +30,16 @@ jobs: sphinx-build docs/source docs/build -b dirhtml # Get version from pyproject.toml. - - name: Extract version - id: get_version + - name: Get version + subdirectory run: | VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['project']['version'])") - echo "version_subdir=versions/$VERSION" >> $GITHUB_OUTPUT + echo "DOCS_SUBDIR=versions/$VERSION" >> $GITHUB_ENV + + # Get version from pyproject.toml. + - name: Override subdirectory to `latest/` for pushes + run: | + echo "DOCS_SUBDIR=latest" >> $GITHUB_ENV + if: github.event_name == 'push' # Deploy to version-dependent subdirectory. - name: Deploy to GitHub Pages @@ -42,8 +47,7 @@ jobs: with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/build - # TODO: only set this to the version number for release actions. - destination_dir: ${{ steps.get_version.outputs.version_subdir }} - keep_files: false # This will only erase the destination subdirectory. + destination_dir: ${{ env.DOCS_SUBDIR }} + keep_files: false # This will only erase the destination subdirectory. cname: viser.studio if: github.event_name != 'pull_request'