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 |
John DeNisco | 92a6ac2 | 2020-03-11 09:47:21 -0400 | [diff] [blame] | 38 | rm -fr sphinx_env |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 39 | git clone ssh://git@github.com/$SITE_USERNAME/site |
| 40 | cd site |
| 41 | git submodule update --init --recursive |
| 42 | git remote add upstream ssh://git@github.com/FDio/site |
| 43 | git remote -v |
| 44 | git fetch upstream |
| 45 | git merge -m "Publish the Docs" upstream/master |
| 46 | |
| 47 | # Get the version |
| 48 | VERSION=`source $WS_ROOT/src/scripts/version` |
| 49 | VERSION=${VERSION/"~"/"-"} |
| 50 | |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 51 | # Copy the files to the appropriate directory |
| 52 | SRC_DIR=../docs/_build/html/. |
| 53 | if [ "$VPP_BRANCH" == "master" ] |
| 54 | then |
| 55 | TARGET_DIR=./static/docs/vpp/master |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 56 | rm -fr $TARGET_DIR |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 57 | else |
| 58 | TARGET_DIR=./static/docs/vpp/v$VPP_BRANCH |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 59 | rm -fr $TARGET_DIR |
| 60 | mkdir -p $TARGET_DIR |
| 61 | VERSION=v$VPP_BRANCH |
John DeNisco | d52820d | 2020-05-29 08:56:38 -0400 | [diff] [blame^] | 62 | rm ./static/docs/vpp/latest |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 63 | ln -s $VERSION ./static/docs/vpp/latest |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 64 | fi |
| 65 | |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 66 | # Create a branch for the commit |
| 67 | git checkout -b $VERSION |
| 68 | git branch |
| 69 | |
| 70 | # Copy the docs |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 71 | cp -r $SRC_DIR $TARGET_DIR |
| 72 | |
John DeNisco | 92a6ac2 | 2020-03-11 09:47:21 -0400 | [diff] [blame] | 73 | # Create the feature list |
| 74 | pushd .. |
| 75 | source ./sphinx_venv/bin/activate |
| 76 | find . -name FEATURE.yaml | ./src/scripts/fts.py --markdown > site/content/vppProject/vppfeatures/features.md |
| 77 | deactivate |
| 78 | popd |
| 79 | |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 80 | # Push the new docs |
John DeNisco | 92a6ac2 | 2020-03-11 09:47:21 -0400 | [diff] [blame] | 81 | git add "*" |
| 82 | git commit -s -m "Publish docs from VPP $VERSION" |
| 83 | git push origin "$VERSION" |
John DeNisco | 73f725c | 2019-10-29 10:40:09 -0400 | [diff] [blame] | 84 | |
| 85 | exit 0 |