fix: use upload github action to public site #15
Workflow file for this run
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
| #=============================================================================== | |
| # Copyright 2024 Intel Corporation | |
| # | |
| # Licensed 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: Docs Release | |
| on: | |
| push: | |
| tags: | |
| - '[0-9][0-9][0-9][0-9].{[0-9],[0-9][0-9]}{,[.][0-9]}' # Trigger on tag pushes | |
| permissions: | |
| contents: read | |
| pages: write # This permission is required for GitHub Pages deployment | |
| id-token: write # This permission is required for GitHub Pages deployment | |
| jobs: | |
| build-docs: | |
| runs-on: ubuntu-24.04 | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Ensures all tags are fetched | |
| - name: Set Up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install System Dependencies | |
| run: sudo apt-get update && sudo apt-get install -y clang-format pandoc | |
| - name: Extract Tag Version | |
| run: | | |
| export DOC_VERSION="${GITHUB_REF#refs/tags/}" | |
| # Error out if cannot find version | |
| if [ -z "$DOC_VERSION" ]; then | |
| echo "::error: Failed to determine documentation version." | |
| exit 1 | |
| fi | |
| export SHORT_DOC_VERSION=$(echo "$DOC_VERSION" | awk -F'.' '{print $1"."$2}') | |
| # export env var in other files | |
| echo "DOC_VERSION=$DOC_VERSION" >> $GITHUB_ENV | |
| echo "SHORT_DOC_VERSION=$SHORT_DOC_VERSION" >> $GITHUB_ENV | |
| - name: Checkout release branch | |
| run: | | |
| if git checkout $DOC_VERSION 2>/dev/null; then | |
| echo "Successfully checked out tag $DOC_VERSION." | |
| else | |
| echo "::error:: Tag $DOC_VERSION does not exist." | |
| exit 1 | |
| fi | |
| git branch | |
| - name: Install Python Dependencies | |
| run: | | |
| pip install daal-devel impi-devel | |
| pip install -r dependencies-dev | |
| pip install -r requirements-doc.txt | |
| - name: Build daal4py/sklearnex | |
| run: | | |
| export DALROOT=$(dirname $(dirname $(which python))) | |
| export LD_LIBRARY_PATH=$(dirname $(dirname $(which python)))/lib:$LD_LIBRARY_PATH | |
| ./conda-recipe/build.sh | |
| - name: Build scikit-learn-intelex Documentation | |
| run: | | |
| export LD_LIBRARY_PATH=$(dirname $(dirname $(which python)))/lib:$LD_LIBRARY_PATH | |
| cd doc | |
| ./build-doc.sh --gh-pages | |
| # - name: Deploy Documentation to gh-pages | |
| # env: | |
| # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # run: | | |
| # # Copy the script to a temp location | |
| # # Otherwise it will get lost after switch branch | |
| # cp .github/scripts/doc_release.sh /tmp/doc_release.sh | |
| # # Set git auth for push changes | |
| # git config --global user.name "GitHub Actions" | |
| # git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| # chmod +x /tmp/doc_release.sh | |
| # /tmp/doc_release.sh | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Prepare Documentation for Deployment | |
| run: | | |
| mkdir -p _site | |
| # Get other versions on gh-pages | |
| if git ls-remote --heads origin gh-pages; then | |
| mkdir -p /tmp/gh-pages | |
| git worktree add --detach /tmp/gh-pages | |
| cd /tmp/gh-pages | |
| git fetch origin gh-pages | |
| git checkout origin/gh-pages | |
| # Copy existing content to _site | |
| cd $GITHUB_WORKSPACE | |
| cp -R /tmp/gh-pages/* _site/ 2>/dev/null || true | |
| # Clean up | |
| git worktree remove --force /tmp/gh-pages | |
| fi | |
| # Copy the new version to _site | |
| mkdir -p _site/$SHORT_DOC_VERSION | |
| cp -R doc/_build/scikit-learn-intelex/$SHORT_DOC_VERSION/* _site/$SHORT_DOC_VERSION/ | |
| # Update latest | |
| rm -rf _site/latest | |
| mkdir -p _site/latest | |
| cp -R doc/_build/scikit-learn-intelex/$SHORT_DOC_VERSION/* _site/latest/ | |
| # Copy index.html | |
| cp doc/_build/scikit-learn-intelex/index.html _site/ | |
| # Generate versions.json | |
| mkdir -p _site/doc | |
| echo "[" > _site/doc/versions.json | |
| # Add latest entry first | |
| echo ' {"name": "latest", "version": "'$SHORT_DOC_VERSION'", "url": "/scikit-learn-intelex/latest/"},' >> _site/doc/versions.json | |
| # Add all year.month folders | |
| for version in $(ls -d _site/[0-9][0-9][0-9][0-9].[0-9]* 2>/dev/null || true); do | |
| version=$(basename "$version") | |
| echo ' {"name": "'$version'", "version": "'$version'", "url": "/scikit-learn-intelex/'$version'/"},' | |
| done | sort -rV >> _site/doc/versions.json | |
| # Remove trailing comma and close array | |
| sed -i '$ s/,$//' _site/doc/versions.json | |
| echo "]" >> _site/doc/versions.json | |
| # Display the content for verification | |
| ls -la _site/ | |
| cat _site/doc/versions.json | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: '_site' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |