-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-switcher.py
69 lines (59 loc) · 1.5 KB
/
update-switcher.py
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
# coding: utf-8
"""Get all tagged releases and build the documentation.
"""
import shutil
import subprocess
import json
import os
import glob
my_env = os.environ.copy()
git_tag = subprocess.run(
" ".join(["git", "tag", "--list", "v*.*.*", "--sort=-version:refname"]),
capture_output=True,
text=True,
shell=True,
)
tags = git_tag.stdout.splitlines()
versions = [
{
"name": "dev",
"version": "dev",
"url": "https://sandialabs.github.io/sansmic/latest/",
"preferred": False,
}
]
with open('stable.txt', 'w') as fout:
fout.write('latest')
to_proc = list()
found_stable = False
stable = False
for tag in tags:
name = tag[1:]
if not found_stable and not "-" in tag:
stable = True
found_stable = tag
name = name + " (stable)"
with open('stable.txt', 'w') as fout:
fout.write(tag)
elif found_stable and "-" in tag:
continue
else:
stable = False
versions.append(
dict(
name=name,
version=tag,
url="https://sandialabs.github.io/sansmic/" + tag + "/",
preferred=stable,
)
)
to_proc.insert(0,tag)
with open('tagged.txt', 'w') as fout:
for tag in to_proc:
fout.write('{}\n'.format(tag))
os.makedirs(os.path.abspath(os.path.join(".","html","_static")), exist_ok=True)
with open(
os.path.abspath(os.path.join(".", "html", "_static", "switcher.json")),
"w",
) as fswitch:
json.dump(versions, fswitch)