-
Notifications
You must be signed in to change notification settings - Fork 105
/
set_version_dirs.sh
executable file
·58 lines (43 loc) · 1.98 KB
/
set_version_dirs.sh
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
#!/bin/bash
# K8S_RELEASE must be set in your environment, for example, 1.17, 1.17.0, 1.18.0-rc.4
if [ -n "${K8S_RELEASE}" ]; then
echo "Setting up reference directories for ${K8S_RELEASE} release."
else
echo "You must set K8S_RELEASE to a release version, such as 1.17.0"
exit 1
fi
ROOTDIR=$(pwd)
echo base dir ${ROOTDIR}
# change <major>.<minor> to <major>_<minor>
VERSION_DIR="$(echo "${K8S_RELEASE}" | cut -c 1-4 | sed "s/\./_/g")"
echo version ${VERSION_DIR}
MINOR_VERSION="$(echo ${VERSION_DIR} | sed "s/[0-9]_//g")"
echo minor version ${MINOR_VERSION}
MAJOR_VERSION="$(echo ${VERSION_DIR} | sed "s/_[0-9]*//g")"
echo major version ${MAJOR_VERSION}
ONE=1
PREV_VERSION_DIR="v""${MAJOR_VERSION}_""$((${MINOR_VERSION} - ${ONE}))"
echo previous version dir ${PREV_VERSION_DIR}
VERSION_DIR="v${VERSION_DIR}"
echo version dir ${VERSION_DIR}
# Set up versioned directories for new release
# kubectl-command static-includes, toc.yaml
mkdir -p ./gen-kubectldocs/generators/${VERSION_DIR}
if ! [ -f "${ROOTDIR}/gen-kubectldocs/generators/${VERSION_DIR}/toc.yaml" ]; then
cp -r ${ROOTDIR}/gen-kubectldocs/generators/${PREV_VERSION_DIR}/* ${ROOTDIR}/gen-kubectldocs/generators/${VERSION_DIR}/
fi
# api reference config.yaml
mkdir -p ${ROOTDIR}/gen-apidocs/config/${VERSION_DIR}
# config.yaml
if ! [ -f "${ROOTDIR}/gen-apidocs/config/${VERSION_DIR}/config.yaml" ]; then
if [ -f "${ROOTDIR}/gen-apidocs/config/${PREV_VERSION_DIR}/config.yaml" ]; then
cp ${ROOTDIR}/gen-apidocs/config/${PREV_VERSION_DIR}/config.yaml ${ROOTDIR}/gen-apidocs/config/${VERSION_DIR}/config.yaml
echo "Using config file: ${ROOTDIR}/gen-apidocs/config/${PREV_VERSION_DIR}/config.yaml"
else
cp ${ROOTDIR}/gen-apidocs/config/config.yaml ${ROOTDIR}/gen-apidocs/config/${VERSION_DIR}/config.yaml
fi
fi
# copy versioned files to the base config dir
# revisit
cp ${ROOTDIR}/gen-apidocs/config/${VERSION_DIR}/config.yaml ${ROOTDIR}/gen-apidocs/config/config.yaml
# api reference swagger.json is copied by updateapispec make target