From dfb35cac1dc2eba728eaf6bb1af7d279f7a90285 Mon Sep 17 00:00:00 2001
From: ambujsingh
Redirecting to latest documentation...
+|\n|" \ + {} + + - name: Verify build output + run: | + if [[ ! -f docs_output/index.html ]]; then + echo "::error::Documentation build failed - no index.html found" + exit 1 + fi + echo "Documentation built successfully" + find docs_output -type f | wc -l | xargs -I{} echo "Total files: {}" + - name: Upload docs to release + if: startsWith(github.ref, 'refs/tags/v') + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + VERSION="${{ steps.version.outputs.version }}" + tar czf "docs-${VERSION}.tar.gz" -C docs_output . + gh release create "${VERSION}" --draft=false --notes "Release ${VERSION}" 2>/dev/null || true + gh release upload "${VERSION}" "docs-${VERSION}.tar.gz" --clobber + - name: Assemble publish tree + if: github.event_name != 'pull_request' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + VERSION="${{ steps.version.outputs.version }}" + IS_TAG="${{ steps.version.outputs.is_tag }}" + REPO_URL="https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}" + + # --- current build --- + mkdir -p "publish/${VERSION}" + cp -a docs_output/. "publish/${VERSION}/" + + # --- restore previously released versions --- + for tag in $(gh api "repos/${{ github.repository }}/releases" --paginate --jq '.[].tag_name' | grep '^v' || true); do + [[ "${tag}" == "${VERSION}" ]] && continue + if gh release download "${tag}" --pattern "docs-${tag}.tar.gz" --dir /tmp 2>/dev/null; then + mkdir -p "publish/${tag}" + tar xzf "/tmp/docs-${tag}.tar.gz" -C "publish/${tag}" + rm -f "/tmp/docs-${tag}.tar.gz" + echo "Restored ${tag} from release artifact" + else + echo "::warning::No docs artifact found for release ${tag}" + fi + done + + # --- set stable alias to newest tagged version --- + if [[ "${IS_TAG}" == "true" ]]; then + cp -a docs_output/. publish/stable/ + else + NEWEST_TAG="$(find publish -maxdepth 1 -mindepth 1 -type d -name 'v*' -printf '%f\n' | sort -rV | head -1)" + if [[ -n "${NEWEST_TAG}" ]]; then + cp -a "publish/${NEWEST_TAG}/." publish/stable/ + fi + fi + + # --- shared assets --- + mkdir -p publish/_shared/css publish/_shared/js + cp docs/_static/css/version_flyout.css publish/_shared/css/ + cp docs/_static/js/version_flyout.js publish/_shared/js/ + + # --- root index & Jekyll bypass --- + cp docs/_gh_pages/index.html publish/index.html + touch publish/.nojekyll + + # --- generate switcher.json --- + { + echo '[' + echo " {\"name\": \"latest\", \"version\": \"latest\", \"url\": \"${REPO_URL}/latest/\"}" + + if [[ -d publish/stable ]]; then + echo " ,{\"name\": \"stable\", \"version\": \"stable\", \"url\": \"${REPO_URL}/stable/\", \"preferred\": true}" + fi + + for dir in $(find publish -maxdepth 1 -mindepth 1 -type d -name 'v*' | sort -rV); do + ver="$(basename "${dir}")" + echo " ,{\"name\": \"${ver}\", \"version\": \"${ver}\", \"url\": \"${REPO_URL}/${ver}/\"}" + done + + echo ']' + } > publish/switcher.json + - name: Upload Pages artifact + if: github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 + with: + path: publish + - name: Print preview URL + if: github.event_name != 'pull_request' + run: | + echo "::notice::Documentation deployed to: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${{ steps.version.outputs.version }}/" + deploy-pages: + needs: build-docs + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/bazel/rules/rules_score/templates/conf.template.py b/bazel/rules/rules_score/templates/conf.template.py index 454254ed..7730c694 100644 --- a/bazel/rules/rules_score/templates/conf.template.py +++ b/bazel/rules/rules_score/templates/conf.template.py @@ -153,4 +153,8 @@ # HTML theme html_theme = "sphinx_rtd_theme" + +# Note: version_flyout.css and version_flyout.js are injected by the +# deploy workflow via _shared/ paths so they load once across all versions. + logger.debug("#" * 80) diff --git a/docs/_gh_pages/index.html b/docs/_gh_pages/index.html new file mode 100644 index 00000000..f25bd0fe --- /dev/null +++ b/docs/_gh_pages/index.html @@ -0,0 +1,26 @@ + + + +
+ +
+ + + +
+