-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_docs_version.sh
More file actions
executable file
·46 lines (37 loc) · 1.43 KB
/
make_docs_version.sh
File metadata and controls
executable file
·46 lines (37 loc) · 1.43 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
#!/bin/bash
# Updates the Read the Docs configuration (docs/source/conf.py) with the
# current version from VERSION.txt and rebuilds the HTML documentation.
#
# Usage:
# ./make_docs_version.sh # update conf.py + rebuild docs
# ./make_docs_version.sh --no-build # update conf.py only
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
VERSION_FILEPATH=${SCRIPT_PATH}/VERSION.txt
CONF_FILEPATH=${SCRIPT_PATH}/docs/source/conf.py
DOCS_DIR=${SCRIPT_PATH}/docs
# Read the current version
FULL_VERSION=$(cat ${VERSION_FILEPATH} | tr -d '[:space:]')
IFS=. read -r MAJOR_VERSION MINOR_VERSION PATCH_VERSION <<< "${FULL_VERSION}"
if [ -z "${MAJOR_VERSION}" ] || [ -z "${MINOR_VERSION}" ] || [ -z "${PATCH_VERSION}" ]; then
echo "Error: Could not parse version from ${VERSION_FILEPATH}"
exit 1
fi
echo "Current version: ${FULL_VERSION}"
# Update release in conf.py
if [ ! -f "${CONF_FILEPATH}" ]; then
echo "Error: conf.py not found at ${CONF_FILEPATH}"
exit 1
fi
echo "Updating ${CONF_FILEPATH}..."
sed -i "s/^release = .*/release = '${FULL_VERSION}'/" "${CONF_FILEPATH}"
echo "Set release = '${FULL_VERSION}' in conf.py"
# Rebuild docs unless --no-build is passed
if [ "$1" != "--no-build" ]; then
echo ""
echo "Rebuilding documentation..."
cd "${DOCS_DIR}"
make clean && make html
echo ""
echo "Documentation built successfully at ${DOCS_DIR}/build/html/"
fi
echo "Docs version updated to ${FULL_VERSION}"