2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 update_file_usage () {
13 echo "Usage: $0 <RELEASE_NAME> <PUBLISH>"
15 echo " RELEASE_NAME: The RELEASE_NAME e.g Magnesium ."
16 echo " PUBLISH: Set to true to PUBLISH"
19 while getopts :h: opts; do
31 set +u # Allow unbound variables for virtualenv
32 virtualenv --quiet "/tmp/v/git-review"
33 # shellcheck source=/tmp/v/git-review/bin/activate disable=SC1091
34 source "/tmp/v/git-review/bin/activate"
35 pip install --quiet --upgrade "pip==9.0.3" setuptools
36 pip install --quiet --upgrade git-review
37 git config --global --add gitreview.username "jenkins-$SILO"
38 cd "$WORKSPACE"/docs || exit
39 RELEASE_NAME=$RELEASE_NAME
40 Next_release="$(tr '[:lower:]' '[:upper:]' <<< "${RELEASE_NAME:0:1}")${RELEASE_NAME:1}" # Captilize Version Name
42 Release_version="$(tr '[:lower:]' '[:upper:]' <<< "${release_name:0:1}")${release_name:1}" # Captilize Version Name
44 stable_release_str=stable-$release_name
45 echo "Start Version Updating in docs project"
46 echo "RELEASE_NAME : $Next_release"
47 if [ "$GERRIT_BRANCH" == "master" ]
49 # ####################################
50 # # Changes in the master branch #
51 # ####################################
53 odl_release_str=odl-$release_name
54 next_odl_release_str=odl-$RELEASE_NAME
55 #change the odl-<release> linking to stable-<release> to odl-<next_release> linking to latest
56 sed -i "s/$odl_release_str/$next_odl_release_str/g;" docs/conf.py
57 sed -i "s/$stable_release_str/latest/g;" docs/conf.py
59 # Get the value of line with odl-<release> linking to stable-<release>
60 # for appending it to the line next to odl-<next_release> linking to latest
61 line_number_nr=$(sed -n "/$next_odl_release_str/=" docs/conf.py)
62 pattern=$line_number_nr"p"
63 odl_latest="sed -n $pattern docs/conf.py"
64 odl_latest_line_value=$($odl_latest)
65 append_odl_latest=$(echo "$odl_latest_line_value" | sed "s/latest/$stable_release_str/g; s/$RELEASE_NAME/$release_name/g" )
66 echo "Making changes in Master Branch"
68 # sed -i "$line_number_nr'i'\
69 # $append_odl_latest" docs/conf.py
70 sed -i "$line_number_nr a $append_odl_latest" docs/conf.py
71 # Updating version in docs/conf.yaml
72 sed -i "s/$Release_version/$Next_release/g" docs/conf.yaml
73 # Updating version in docs/javadoc.rst
74 sed -i "s/$release_name/$RELEASE_NAME/g" docs/javadoc.rst
75 if [ "$PUBLISH" == "true" ]
77 git add docs/conf.py docs/conf.yaml docs/javadoc.rst
78 echo "Update configuratiom files in master branch"
79 git commit -s -m "Update configuratiom files in master branch
81 In docs/conf.py , add odl-$RELEASE_NAME pointing to latest
82 and change odl-$release_name to point to stable-$release_name.
84 Change version from $Release_version to $Next_release.
86 Change links from $release_name to $RELEASE_NAME"
90 ####################################
91 # Changes in the new stable branch #
92 ####################################
93 echo "Making changes in $GERRIT_BRANCH"
95 # #Updating links in docs/conf.py
96 sed -i "s/latest/$stable_release_str/g" docs/conf.py
97 if [ "$PUBLISH" == "true" ]
100 echo "Update docs/conf.py links from latest to $stable_release_str"
101 git commit -s -m "Update docs/conf.py links from latest to $stable_release_str
103 Should be $stable_release_str on ${GERRIT_BRANCH}."