-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdocs.sh
More file actions
executable file
·58 lines (48 loc) · 1.36 KB
/
Copy pathdocs.sh
File metadata and controls
executable file
·58 lines (48 loc) · 1.36 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Function to validate version number format (x.y.z)
validate_version() {
if [[ ! $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version number must be in format x.y.z (e.g., 0.12.0)"
exit 1
fi
}
# Check if version argument is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <version>"
echo "Example: $0 0.11.0"
exit 1
fi
VERSION="${1#v}"
DOCS_ROOT="${DOCS_ROOT:-www}"
ROC_BIN="${ROC:-roc}"
if [[ "$ROC_BIN" == */* ]]; then
ROC_BIN="$(cd "$(dirname "$ROC_BIN")" && pwd)/$(basename "$ROC_BIN")"
fi
# Validate version number
validate_version "$VERSION"
rm -rf "$DOCS_ROOT/$VERSION"
mkdir -p "$DOCS_ROOT"
"$ROC_BIN" docs package/main.roc --output="$DOCS_ROOT/$VERSION"
cat > "$DOCS_ROOT/index.html" <<EOF
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Redirecting...</title>
<script>
window.location.href = "/roc-parser/$VERSION/";
</script>
</head>
<body>
<noscript>
<p>
If you are not automatically redirected, please
<a href="/roc-parser/$VERSION/">click here</a>.
</p>
</noscript>
</body>
</html>
EOF
echo "Generated docs for $VERSION in $DOCS_ROOT/$VERSION"