Docs Release #10
Workflow file for this run
This file contains 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]*" # Trigger on tag pushes | |
jobs: | |
build-docs: | |
runs-on: ubuntu-latest | |
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@v4 | |
with: | |
python-version: "3.11" | |
- name: Install System Dependencies | |
run: sudo apt-get update && sudo apt-get install -y clang-format pandoc | |
- name: Extract Tag Version | |
run: | | |
echo "GITHUB_REF: $GITHUB_REF" | |
export DOC_VERSION="${GITHUB_REF#refs/tags/}" | |
# Error iif 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}') | |
echo "DOC_VERSION: $DOC_VERSION $SHORT_DOC_VERSION" | |
echo "doc version can be found" | |
# export env var in other files | |
echo "DOC_VERSION=$DOC_VERSION" >> $GITHUB_ENV | |
echo "SHORT_DOC_VERSION=$SHORT_DOC_VERSION" >> $GITHUB_ENV | |
echo "can set short doc version" | |
- name: Checkout release brance | |
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 | |
echo "Can checkout release brance" | |
- name: Install Python Dependencies | |
run: | | |
pip install daal-devel impi-devel | |
pip install -r dependencies-dev | |
pip install -r requirements-doc.txt | |
pip install -r requirements-test.txt | |
pip list | |
- 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 daal4py Documentation | |
run: | | |
export LD_LIBRARY_PATH=$(dirname $(dirname $(which python)))/lib:$LD_LIBRARY_PATH | |
cd doc/daal4py | |
make html 2>&1 | tee build.log | |
cat build.log | |
if grep -i "autodoc" build.log; then | |
echo "Autodoc Warnings detected, build failed!" | |
exit 1 | |
fi | |
- 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 | |
echo "doc build folder" | |
ls _build/scikit-learn-intelex | |
- name: Modify version json file | |
run: | | |
BUILD_DIR="doc/_build/scikit-learn-intelex" | |
echo "BUILD_DIR=$BUILD_DIR" >> $GITHUB_ENV | |
export VERSIONS_FILE="$BUILD_DIR/versions.json" | |
if [ ! -f "$VERSIONS_FILE" ]; then | |
echo "ERROR: $VERSIONS_FILE does not exist!" | |
exit 1 | |
fi | |
jq --arg version "$SHORT_DOC_VERSION" '. |= [{"name": $version, "version": $version, "url": ("/scikit-learn-intelex/" + $version + "/")}] + .' "$VERSIONS_FILE" > tmp.json && mv tmp.json "$VERSIONS_FILE" | |
jq --arg version "$SHORT_DOC_VERSION" '(.[] | select(.name == "latest")) .version = $version' "$VERSIONS_FILE" > tmp.json && mv tmp.json "$VERSIONS_FILE" | |
echo "Updated versions.json:" | |
cat "$VERSIONS_FILE" | |
ls | |
- name: Deploy Documentation to gh-pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Define paths | |
DEPLOY_DIR="/tmp/gh-pages-deploy" | |
# Ensure the build directory exists | |
if [ ! -d "$BUILD_DIR" ]; then | |
echo "ERROR: Documentation build directory not found!" | |
exit 1 | |
fi | |
# Copy built documentation to a temp location | |
mkdir -p "$DEPLOY_DIR" | |
cp -R "$BUILD_DIR"/* "$DEPLOY_DIR" | |
ls $DEPLOY_DIR | |
# Checkout gh-pages branch | |
git fetch origin gh-pages | |
git checkout gh-pages | |
#TODO delete this temp code | |
BACKUP_DIR="backup" | |
mkdir -p "$BACKUP_DIR" | |
cp -R latest "$BACKUP_DIR/latest_backup" | |
cp versions.json "$BACKUP_DIR/versions.json_backup" | |
cp index.html "$BACKUP_DIR/index.html_backup" | |
echo "cur after checkout to gh-pages" | |
ls | |
# Move the new versioned folder to the correct location | |
rm -rf latest | |
cp -R "$DEPLOY_DIR/$SHORT_DOC_VERSION" latest | |
cp "$DEPLOY_DIR/index.html" . | |
cp "$DEPLOY_DIR/versions.json" . | |
echo "cur after move folder in" | |
ls | |
cat versions.json | |
ls latest | |
# Commit and push changes | |
git add . | |
git commit -m "Automatic doc update for version $DOC_VERSION" | |
git push origin gh-pages |