-
Notifications
You must be signed in to change notification settings - Fork 247
82 lines (79 loc) · 3.36 KB
/
publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: Publish
on:
push:
branches:
- docs
jobs:
build:
runs-on: self-hosted
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: docs
- name: Create symlinks for the latest doc version
run: |
export PATH="$HOME/.local/bin:$PATH"
echo -e "import argparse\nfrom os import listdir\nfrom os.path import isdir, join\nimport re\nclass cDirs:\n def __init__(self, str_ver):\n self.major = 0\n self.minor = 0\n self.patch = 0\n self.post = ''\n matches = re.match('(\d+)\.(\d+)\.(\d+)(.*)', str_ver)\n if matches and len(matches.groups()) == 4:\n self.major = int(matches.group(1))\n self.minor = int(matches.group(2))\n self.patch = int(matches.group(3))\n self.post = matches.group(4)\n def __repr__(self):\n return f'{self.major}.{self.minor}.{self.patch}{self.post}'\nparser = argparse.ArgumentParser()\nparser.add_argument('path')\nargs = parser.parse_args()\ndirs = [cDirs(d) for d in listdir(args.path) if isdir(join(args.path, d)) and d != '.git']\ndirs.sort(key=lambda x: (x.major, x.minor, x.patch, x.post), reverse=True)\nfor d in dirs:\n if str(d) != '0.0.0':\n print(d)" > versions_scan.py
LATEST_CPU=""
LATEST_XPU=""
sed -i "/<li class=\"toctree-l1\">/d" index.html
txt="\ <li class=\"toctree-l1\"><a class=\"reference internal\" href=\"cpu/latest\">latest</a></li>"
while read -r line;
do
if [ -z ${LATEST_CPU} ]; then
LATEST_CPU=${line}
fi
txt="${txt}\n <li class=\"toctree-l1\"><a class=\"reference internal\" href=\"cpu/${line}\">v${line}</a></li>"
done < <(python versions_scan.py ./cpu)
ln=$(grep "<ul id=\"ul_cpu\">" -n index.html | cut -d ":" -f 1)
ln=$((ln+1))
sed -i "${ln} i ${txt}" index.html
txt="\ <li class=\"toctree-l1\"><a class=\"reference internal\" href=\"xpu/latest\">latest</a></li>"
while read -r line;
do
if [ -z ${LATEST_XPU} ]; then
LATEST_XPU=${line}
fi
txt="${txt}\n <li class=\"toctree-l1\"><a class=\"reference internal\" href=\"xpu/${line}\">v${line}</a></li>"
done < <(python versions_scan.py ./xpu)
ln=$(grep "<ul id=\"ul_gpu\">" -n index.html | cut -d ":" -f 1)
ln=$((ln+1))
sed -i "${ln} i ${txt}" index.html
cd cpu
if [ -L latest ]; then
rm latest
fi
ln -s ${LATEST_CPU} latest
cd ../xpu
if [ -L latest ]; then
rm latest
fi
ln -s ${LATEST_XPU} latest
cd ..
if [ -L latest ]; then
rm latest
fi
ln -s cpu/latest latest
rm versions_scan.py
if [ ! -f .nojekyll ]; then
touch .nojekyll
fi
- name: Upload Artifact
uses: actions/upload-pages-artifact@v2
with:
path: '.'
deploy:
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{steps.depolyment.outputs.page_url}}
runs-on: self-hosted
needs: build
steps:
- name: Deploy
id: deployment
uses: actions/deploy-pages@v2