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 if [ "$GERRIT_PROJECT" == "docs" ]; then
32 RELEASE_NAME=$RELEASE_NAME
33 Next_release="$(tr '[:lower:]' '[:upper:]' <<< "${RELEASE_NAME:0:1}")${RELEASE_NAME:1}" # Captilize Version Name
35 Release_version="$(tr '[:lower:]' '[:upper:]' <<< "${release_name:0:1}")${release_name:1}" # Captilize Version Name
37 stable_release_str=stable-$release_name
38 echo "Start Version Updating in docs project"
39 echo "RELEASE_NAME : $Next_release"
40 pip install --user --quiet --upgrade git-review
41 git config --global --add gitreview.username "jenkins-$SILO"
42 if [ "$GERRIT_BRANCH" == "master" ]
44 # ####################################
45 # # Changes in the master branch #
46 # ####################################
48 odl_release_str=odl-$release_name
49 next_odl_release_str=odl-$RELEASE_NAME
50 #change the odl-<release> linking to stable-<release> to odl-<next_release> linking to latest
51 sed -i "s/$odl_release_str/$next_odl_release_str/g;" docs/conf.py
52 sed -i "s/$stable_release_str/latest/g;" docs/conf.py
54 # Get the value of line with odl-<release> linking to stable-<release>
55 # for appending it to the line next to odl-<next_release> linking to latest
56 line_number_nr=$(sed -n "/$next_odl_release_str/=" docs/conf.py)
57 pattern=$line_number_nr"p"
58 odl_latest="sed -n $pattern docs/conf.py"
59 odl_latest_line_value=$($odl_latest)
60 append_odl_latest=$(echo "$odl_latest_line_value" | sed "s/latest/$stable_release_str/g; s/$RELEASE_NAME/$release_name/g" )
61 echo "Making changes in Master Branch"
63 # sed -i "$line_number_nr'i'\
64 # $append_odl_latest" docs/conf.py
65 sed -i "$line_number_nr a $append_odl_latest" docs/conf.py
66 # Updating version in docs/conf.yaml
67 sed -i "s/$Release_version/$Next_release/g" docs/conf.yaml
68 # Updating version in docs/javadoc.rst
69 sed -i "s/$release_name/$RELEASE_NAME/g" docs/javadoc.rst
70 if [ "$PUBLISH" == "true" ]
72 git add docs/conf.py docs/conf.yaml docs/javadoc.rst
73 echo "Update configuratiom files in master branch"
74 git commit -s -m "Update configuratiom files in master branch
76 In docs/conf.py , add odl-$RELEASE_NAME pointing to latest
77 and change odl-$release_name to point to stable-$release_name.
79 Change version from $Release_version to $Next_release.
81 Change links from $release_name to $RELEASE_NAME"
85 ####################################
86 # Changes in the new stable branch #
87 ####################################
88 echo "Making changes in $GERRIT_BRANCH"
90 # #Updating links in docs/conf.py
91 sed -i "s/latest/$stable_release_str/g" docs/conf.py
92 if [ "$PUBLISH" == "true" ]
95 echo "Update docs/conf.py links from latest to $stable_release_str"
96 git commit -s -m "Update docs/conf.py links from latest to $stable_release_str
98 Should be $stable_release_str on ${GERRIT_BRANCH}."