66  workflow_dispatch : #  or run on manual trigger
77
88jobs :
9+   define-version-matrix :
10+     runs-on : ubuntu-latest 
11+     outputs :
12+       matrix : ${{ steps.set-matrix.outputs.matrix }} 
13+     steps :
14+       - id : set-matrix 
15+         env :
16+           GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
17+         run : | 
18+           OLDEST_SUPPORTED_VERSION="0.6.0" 
19+           versions=$(gh release -R redis/redis-vl-python list --json name,isLatest \ 
20+             | jq -r '.[] | [.name, .isLatest] | @tsv' \ 
21+             | sed "/${OLDEST_SUPPORTED_VERSION}/q" \ 
22+             | jq -Rnc '{include: [inputs | split("\t") | {version: .[0], isLatest: .[1]}]}') 
23+ 
24+           echo "${versions}" 
25+           echo "matrix=${versions}" >> "$GITHUB_OUTPUT" 
26+ 
927   redisvl_docs_sync :
1028    runs-on : ubuntu-latest 
29+     needs : define-version-matrix 
30+     strategy :
31+       matrix : ${{ fromJSON(needs['define-version-matrix'].outputs.matrix) }} 
32+       fail-fast : false 
1133    permissions :
1234      contents : write 
1335      pull-requests : write 
@@ -30,20 +52,25 @@ jobs:
3052        env :
3153          GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
3254        run : | 
33-           pushd redis-vl-python 
55+           version="${{ matrix.version }}" 
56+           isLatest="${{ matrix.isLatest }}" 
3457
35-           # Get latest release 
36-           latest_release=$(gh release -R redis/redis-vl-python list --json name,isLatest --jq '.[] | select(.isLatest)|.name') 
37-           git checkout "tags/${latest_release}" || git checkout "tags/v${latest_release}" 
58+           pushd redis-vl-python 
59+           git checkout "tags/${version}" || git checkout "tags/v${version}" 
3860          pip3 install -e . 
39- 
4061          popd 
41-           sphinx-build -M markdown ./redis-vl-python/docs ./build 
42-            
43-           echo "release=${latest_release}" >> "$GITHUB_OUTPUT" 
62+ 
63+           if [ ${isLatest} = true ]; then 
64+             sphinx-build -M markdown ./redis-vl-python/docs ./build-latest 
65+           else 
66+             sphinx-build -M markdown ./redis-vl-python/docs ./build-${version} 
67+           fi 
4468
4569       - name : ' Format markdown files for hugo compatibility' 
4670        run : | 
71+           version="${{ matrix.version }}" 
72+           isLatest="${{ matrix.isLatest }}" 
73+ 
4774          #!/bin/bash 
4875          mkdir -p redis_vl_hugo/user_guide/ 
4976          mkdir redis_vl_hugo/overview/ 
@@ -65,13 +92,22 @@ jobs:
6592              alias=$(echo ${src} | sed -E 's|./redis_vl_hugo/|/integrate/redisvl/| ; s|\.md$|| ; s|\/_index$||') 
6693
6794              # Inject frontmatter in destination file 
95+               if [ ${isLatest} = true ]; then 
6896              cat >_tmp <<EOL 
6997          --- 
7098          linkTitle: ${linkTitle} 
7199          title: ${title} 
72100          aliases: 
73101          - ${alias} 
74102          EOL 
103+               else 
104+               cat >_tmp <<EOL 
105+           --- 
106+           linkTitle: ${linkTitle} 
107+           title: ${title} 
108+           EOL 
109+               fi 
110+ 
75111
76112              # Inject weight property for index pages to preserve order 
77113              case "${title}" in 
@@ -110,12 +146,13 @@ jobs:
110146          } 
111147
112148          # Convert jupyter notebooks to markdown 
113-           jupyter nbconvert --to markdown build/jupyter_execute/user_guide/*.ipynb --output-dir redis_vl_hugo/user_guide/ 2>/dev/null 
114-           jupyter nbconvert --to markdown build/jupyter_execute/overview/cli.ipynb --output-dir redis_vl_hugo/overview/ 2>/dev/null 
149+           build_folder=$(echo build-*) 
150+           jupyter nbconvert --to markdown ${build_folder}/jupyter_execute/user_guide/*.ipynb --output-dir redis_vl_hugo/user_guide/ 2>/dev/null 
151+           jupyter nbconvert --to markdown ${build_folder}/jupyter_execute/overview/cli.ipynb --output-dir redis_vl_hugo/overview/ 2>/dev/null 
115152
116153          # Prepare markdown files 
117-           rsync -a ./build /markdown/api/ ./redis_vl_hugo/api/ --exclude=index.md 
118-           cp ./build /markdown/overview/installation.md ./redis_vl_hugo/overview/installation.md 
154+           rsync -a ./${build_folder} /markdown/api/ ./redis_vl_hugo/api/ --exclude=index.md 
155+           cp ./${build_folder} /markdown/overview/installation.md ./redis_vl_hugo/overview/installation.md 
119156
120157          # Format markdown files 
121158          shopt -s globstar 
@@ -211,9 +248,9 @@ jobs:
211248          done 
212249
213250          # Format _index.md pages 
214-           cp ./build /markdown/api/index.md ./redis_vl_hugo/api/_index.md 
215-           cp ./build /markdown/user_guide/index.md ./redis_vl_hugo/user_guide/_index.md 
216-           cp ./build /markdown/overview/index.md ./redis_vl_hugo/overview/_index.md 
251+           cp ./${build_folder} /markdown/api/index.md ./redis_vl_hugo/api/_index.md 
252+           cp ./${build_folder} /markdown/user_guide/index.md ./redis_vl_hugo/user_guide/_index.md 
253+           cp ./${build_folder} /markdown/overview/index.md ./redis_vl_hugo/overview/_index.md 
217254
218255          index_markdown_pages=( 
219256              ./redis_vl_hugo/api/_index.md 
@@ -237,13 +274,21 @@ jobs:
237274              fi 
238275          done 
239276
240-           cp -r redis_vl_hugo/* content/develop/ai/redisvl/ 
277+           if [ ${isLatest} = true ]; then 
278+             cp -r redis_vl_hugo/* content/develop/ai/redisvl/ 
279+           else 
280+             mkdir -p content/develop/ai/redisvl/${version}/ 
281+             cp -r redis_vl_hugo/* content/develop/ai/redisvl/${version}/ 
282+             cp content/develop/ai/redisvl/_index.md content/develop/ai/redisvl/${version}/_index.md 
283+             cp content/develop/ai/redisvl/install.md content/develop/ai/redisvl/${version}/install.md 
284+             python3 build/version_archiver.py redisvl ${version} --skip-archive 
285+           fi 
241286
242287       - name : ' Create pull request if necessary' 
243288        env :
244289          GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} 
245290        run : | 
246-           release="${{ steps.sphinx.outputs.release  }}" 
291+           release="${{ matrix.version  }}" 
247292          branch="redisvl_docs_sync_${release}" 
248293          redisvl_change=false 
249294
@@ -254,7 +299,7 @@ jobs:
254299          if [ "$?" -eq 0 ]; then 
255300            set -e 
256301            # if it does, create local branch off existing remote branch 
257-             git checkout -b "${branch}" "origin/${branch}" 
302+             git checkout -f - b "${branch}" "origin/${branch}" 
258303            git branch --set-upstream-to="origin/${branch}" "${branch}" 
259304            git pull 
260305          else 
@@ -263,9 +308,11 @@ jobs:
263308            git checkout -b "${branch}" 
264309          fi 
265310
266-           redisvl_is_different=$(git diff content/develop/ai/redisvl/) 
311+           set +e 
312+           latest_redisvl_release_is_different=$(git diff content/develop/ai/redisvl/) 
313+           new_release=$(git ls-files --others --directory | grep content/develop/ai/redisvl/${release}) 
267314
268-           if [[ ! -z $redisvl_is_different  ]]; then 
315+           if [[ -n "$latest_redisvl_release_is_different" || -n "$new_release"  ]]; then 
269316            redisvl_change=true 
270317
271318            git add "content/develop/ai/redisvl/" 
0 commit comments