blob: bd1a9eae3b3bd3ec6e48f46053e369fc67dc9377 [file] [log] [blame]
John DeNisco73f725c2019-10-29 10:40:09 -04001#!/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
14if [ ! -d "docs" ]; then
15 echo "This script is meant to be run from the root directory."
16 exit 1;
17fi
18
19if [ "$#" -ne 2 ]; then
20 echo "Please specify the site username and branch."
21 exit 1;
22fi
23
24# Get the workspace root
25WS_ROOT=$PWD
26
27# Get the VPP branch and username
28SITE_USERNAME=$1
29VPP_BRANCH=$2
30
31#Build the docs
John DeNiscoa273ce62020-01-24 14:04:41 -050032make docs-clean
John DeNisco73f725c2019-10-29 10:40:09 -040033make docs-venv
34make docs
35
36# Clone the site repo
37rm -fr site
John DeNisco92a6ac22020-03-11 09:47:21 -040038rm -fr sphinx_env
John DeNisco73f725c2019-10-29 10:40:09 -040039git clone ssh://git@github.com/$SITE_USERNAME/site
40cd site
41git submodule update --init --recursive
42git remote add upstream ssh://git@github.com/FDio/site
43git remote -v
44git fetch upstream
45git merge -m "Publish the Docs" upstream/master
46
47# Get the version
48VERSION=`source $WS_ROOT/src/scripts/version`
49VERSION=${VERSION/"~"/"-"}
50
John DeNisco73f725c2019-10-29 10:40:09 -040051# Copy the files to the appropriate directory
52SRC_DIR=../docs/_build/html/.
53if [ "$VPP_BRANCH" == "master" ]
54then
55 TARGET_DIR=./static/docs/vpp/master
John DeNiscoa273ce62020-01-24 14:04:41 -050056 rm -fr $TARGET_DIR
John DeNisco73f725c2019-10-29 10:40:09 -040057else
58 TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH
John DeNiscoa273ce62020-01-24 14:04:41 -050059 rm -fr $TARGET_DIR
60 mkdir -p $TARGET_DIR
61 VERSION=v$VPP_BRANCH
62 ln -s $VERSION ./static/docs/vpp/latest
John DeNisco73f725c2019-10-29 10:40:09 -040063fi
64
John DeNiscoa273ce62020-01-24 14:04:41 -050065# Create a branch for the commit
66git checkout -b $VERSION
67git branch
68
69# Copy the docs
John DeNisco73f725c2019-10-29 10:40:09 -040070cp -r $SRC_DIR $TARGET_DIR
71
John DeNisco92a6ac22020-03-11 09:47:21 -040072# Create the feature list
73pushd ..
74source ./sphinx_venv/bin/activate
75find . -name FEATURE.yaml | ./src/scripts/fts.py --markdown > site/content/vppProject/vppfeatures/features.md
76deactivate
77popd
78
John DeNisco73f725c2019-10-29 10:40:09 -040079# Push the new docs
John DeNisco92a6ac22020-03-11 09:47:21 -040080git add "*"
81git commit -s -m "Publish docs from VPP $VERSION"
82git push origin "$VERSION"
John DeNisco73f725c2019-10-29 10:40:09 -040083
84exit 0