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