9cbef8ddc9a6e9ea4780ee63542181c824684a77
[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 git clone ssh://git@github.com/$SITE_USERNAME/site
39 cd site
40 git submodule update --init --recursive
41 git remote add upstream ssh://git@github.com/FDio/site
42 git remote -v
43 git fetch upstream
44 git merge -m "Publish the Docs" upstream/master
45
46 # Get the version
47 VERSION=`source $WS_ROOT/src/scripts/version`
48 VERSION=${VERSION/"~"/"-"}
49
50 # Copy the files to the appropriate directory
51 SRC_DIR=../docs/_build/html/.
52 if [ "$VPP_BRANCH" == "master" ]
53 then
54     TARGET_DIR=./static/docs/vpp/master
55     rm -fr $TARGET_DIR
56 else
57     TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH
58     rm -fr $TARGET_DIR
59     mkdir -p $TARGET_DIR
60     VERSION=v$VPP_BRANCH
61     ln -s $VERSION ./static/docs/vpp/latest
62 fi
63
64 # Create a branch for the commit
65 git checkout -b $VERSION
66 git branch
67
68 # Copy the docs
69 cp -r $SRC_DIR $TARGET_DIR
70
71 # Push the new docs
72 #git add "*"
73 #git commit -s -m "Publish docs from VPP $VERSION"
74 #git push origin "$VERSION"
75
76 exit 0