docs: Add feature build to publish script
[vpp.git] / docs / scripts / publish-docs.sh
1 #!/bin/bash -ex
2
3 # publish-docs.sh
4 #
5 # This sccript is used to publish the VPP User documents to
6 # the FD.io Site.
7 #
8 # Arguments:
9 #
10 # $1: The main site repo user name
11 # $2: The release branch name for example 1908, 1904 etc.
12
13 # Some basic checks
14 if [ ! -d "docs" ]; then
15   echo "This script is meant to be run from the root directory."
16   exit 1;
17 fi
18
19 if [ "$#" -ne 2 ]; then
20     echo "Please specify the site username and branch."
21     exit 1;
22 fi
23
24 # Get the workspace root
25 WS_ROOT=$PWD
26
27 # Get the VPP branch and username
28 SITE_USERNAME=$1
29 VPP_BRANCH=$2
30
31 #Build the docs
32 make docs-clean
33 make docs-venv
34 make docs
35
36 # Clone the site repo
37 rm -fr site
38 rm -fr sphinx_env
39 git clone ssh://git@github.com/$SITE_USERNAME/site
40 cd site
41 git submodule update --init --recursive
42 git remote add upstream ssh://git@github.com/FDio/site
43 git remote -v
44 git fetch upstream
45 git merge -m "Publish the Docs" upstream/master
46
47 # Get the version
48 VERSION=`source $WS_ROOT/src/scripts/version`
49 VERSION=${VERSION/"~"/"-"}
50
51 # Copy the files to the appropriate directory
52 SRC_DIR=../docs/_build/html/.
53 if [ "$VPP_BRANCH" == "master" ]
54 then
55     TARGET_DIR=./static/docs/vpp/master
56     rm -fr $TARGET_DIR
57 else
58     TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH
59     rm -fr $TARGET_DIR
60     mkdir -p $TARGET_DIR
61     VERSION=v$VPP_BRANCH
62     ln -s $VERSION ./static/docs/vpp/latest
63 fi
64
65 # Create a branch for the commit
66 git checkout -b $VERSION
67 git branch
68
69 # Copy the docs
70 cp -r $SRC_DIR $TARGET_DIR
71
72 # Create the feature list
73 pushd ..
74 source ./sphinx_venv/bin/activate
75 find . -name FEATURE.yaml | ./src/scripts/fts.py --markdown > site/content/vppProject/vppfeatures/features.md
76 deactivate
77 popd
78
79 # Push the new docs
80 git add "*"
81 git commit -s -m "Publish docs from VPP $VERSION"
82 git push origin "$VERSION"
83
84 exit 0