Skip to content

Commit

Permalink
[docs] Build versions.json before mike deploy (#3392)
Browse files Browse the repository at this point in the history
* Fixes generated versions.json issue

---------

Co-authored-by: Frank Liu <[email protected]>
  • Loading branch information
Varun-Dutta and frankfliu authored Aug 7, 2024
1 parent 690df2d commit 135fc56
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
with:
path: docs/demos/jupyter
key: ${{ runner.os }}-jupyter-${{ hashFiles('docs/demos/jupyter/*') }}

- name: Run Notebooks
if: steps.jupyter-notebooks-cache.outputs.cache-hit != 'true'
working-directory: docs/demos/jupyter
Expand All @@ -90,11 +90,11 @@ jobs:
aws-region: us-east-2

- name: Copy files to S3 with the AWS CLI
env:
DJL_VERSION: ${{ github.event.inputs.pt_version || 'master' }}
env:
DJL_VERSION: ${{ github.event.inputs.version-number || 'master' }}
run: |
aws s3 sync $DJL_VERSION s3://djl-ai/documentation/nightly/$DJL_VERSION --delete
aws s3 cp versions.json s3://djl-ai/documentation/nightly/versions.json
aws s3 sync $DJL_VERSION s3://djl-ai/documentation/$DJL_VERSION --delete
aws s3 cp versions.json s3://djl-ai/documentation/versions.json
aws cloudfront create-invalidation --distribution-id E733IIDCG0G5U --paths "/*"
31 changes: 18 additions & 13 deletions tools/scripts/build-website.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,36 @@

set -ex

REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"

VERSION_NUMBER=$1
if [[ "$VERSION_NUMBER" == "" ]]; then
VERSION_NUMBER=master
fi

BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

echo "Updating online runner ..."
python3 "$BASE_DIR/add_online_runner.py"
python3 "$REPO_ROOT/tools/scripts/add_online_runner.py"

# Configure Git User, mike will create gh-pages branch
git config user.name "nobody"
git config user.email "nobody@localhost"

echo "Building docs for $VERSION_NUMBER"
mike deploy "$VERSION_NUMBER" -F docs/mkdocs.yml -b gh-pages

git checkout gh-pages
if [[ -z "$(git config user.name)" ]]; then
git config user.name "nobody"
fi
if [[ -z "$(git config user.email)" ]]; then
git config user.email "nobody@localhost"
fi

echo "generating versions.json"
current_version=$(awk -F '=' '/djl / {gsub(/ ?"/, "", $2); print $2}' "$BASE_DIR/../../gradle/libs.versions.toml" | awk -F '.' '{print $2}')
current_version=$(awk -F '=' '/djl / {gsub(/ ?"/, "", $2); print $2}' "gradle/libs.versions.toml" | awk -F '.' '{print $2}')
versions='[{"version":"master","title":"master","aliases":[]}'
for i in {1..4}; do
version="0.$((current_version - i)).0"
versions="$versions, {\"version\":\"$version\",\"title\":\"$version\",\"aliases\":[]}"
versions="$versions, {\"version\":\"v$version\",\"title\":\"v$version\",\"aliases\":[]}"
done
versions="$versions]"
echo "$versions" | jq "." > "$BASE_DIR/../../versions.json"

echo "Building docs for $VERSION_NUMBER"
mike deploy "$VERSION_NUMBER" -F docs/mkdocs.yml -b gh-pages

git checkout gh-pages

echo "$versions" | jq "." >"$REPO_ROOT/versions.json"

0 comments on commit 135fc56

Please sign in to comment.