blob: 026ab2f3907b5a0c9178a0ff8e99e4985058a7ac [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
John DeNiscod52820d2020-05-29 08:56:38 -040062 rm ./static/docs/vpp/latest
John DeNiscoa273ce62020-01-24 14:04:41 -050063 ln -s $VERSION ./static/docs/vpp/latest
John DeNisco73f725c2019-10-29 10:40:09 -040064fi
65
John DeNiscoa273ce62020-01-24 14:04:41 -050066# Create a branch for the commit
67git checkout -b $VERSION
68git branch
69
70# Copy the docs
John DeNisco73f725c2019-10-29 10:40:09 -040071cp -r $SRC_DIR $TARGET_DIR
72
John DeNisco92a6ac22020-03-11 09:47:21 -040073# Create the feature list
74pushd ..
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020075source ./docs/venv/bin/activate
John DeNisco92a6ac22020-03-11 09:47:21 -040076find . -name FEATURE.yaml | ./src/scripts/fts.py --markdown > site/content/vppProject/vppfeatures/features.md
77deactivate
78popd
79
John DeNisco73f725c2019-10-29 10:40:09 -040080# Push the new docs
John DeNisco92a6ac22020-03-11 09:47:21 -040081git add "*"
82git commit -s -m "Publish docs from VPP $VERSION"
83git push origin "$VERSION"
John DeNisco73f725c2019-10-29 10:40:09 -040084
85exit 0