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 |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame^] | 32 | make docs-clean |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 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 | |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 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 |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame^] | 55 | rm -fr $TARGET_DIR |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 56 | else |
| 57 | TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame^] | 58 | rm -fr $TARGET_DIR |
| 59 | mkdir -p $TARGET_DIR |
| 60 | VERSION=v$VPP_BRANCH |
| 61 | ln -s $VERSION ./static/docs/vpp/latest |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 62 | fi |
| 63 | |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame^] | 64 | # Create a branch for the commit |
| 65 | git checkout -b $VERSION |
| 66 | git branch |
| 67 | |
| 68 | # Copy the docs |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 69 | cp -r $SRC_DIR $TARGET_DIR |
| 70 | |
| 71 | # Push the new docs |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame^] | 72 | #git add "*" |
| 73 | #git commit -s -m "Publish docs from VPP $VERSION" |
| 74 | #git push origin "$VERSION" |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 75 | |
| 76 | exit 0 |