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 if [ "$GERRIT_BRANCH" == "master" ]
42 # ####################################
43 # # Changes in the master branch #
44 # ####################################
46 odl_release_str=odl-$release_name
47 next_odl_release_str=odl-$RELEASE_NAME
48 #change the odl-<release> linking to stable-<release> to odl-<next_release> linking to latest
49 sed -i "s/$odl_release_str/$next_odl_release_str/g;" docs/conf.py
50 sed -i "s/$stable_release_str/latest/g;" docs/conf.py
52 # Get the value of line with odl-<release> linking to stable-<release>
53 # for appending it to the line next to odl-<next_release> linking to latest
54 line_number_nr=$(sed -n "/$next_odl_release_str/=" docs/conf.py)
55 pattern=$line_number_nr"p"
56 odl_latest="sed -n $pattern docs/conf.py"
57 odl_latest_line_value=$($odl_latest)
58 append_odl_latest=$(echo "$odl_latest_line_value" | sed "s/latest/$stable_release_str/g; s/$RELEASE_NAME/$release_name/g" )
59 echo "Making changes in Master Branch"
61 # sed -i "$line_number_nr'i'\
62 # $append_odl_latest" docs/conf.py
63 sed -i "$line_number_nr a $append_odl_latest" docs/conf.py
64 # Updating version in docs/conf.yaml
65 sed -i "s/$Release_version/$Next_release/g" docs/conf.yaml
66 # Updating version in docs/javadoc.rst
67 sed -i "s/$release_name/$RELEASE_NAME/g" docs/javadoc.rst
68 if [ "$PUBLISH" == "true" ]
70 git add docs/conf.py docs/conf.yaml docs/javadoc.rst
71 echo "Update configuratiom files in master branch"
72 git commit -s -m "Update configuratiom files in master branch
74 In docs/conf.py , add odl-$RELEASE_NAME pointing to latest
75 and change odl-$release_name to point to stable-$release_name.
77 Change version from $Release_version to $Next_release.
79 Change links from $release_name to $RELEASE_NAME"
83 ####################################
84 # Changes in the new stable branch #
85 ####################################
86 echo "Making changes in $GERRIT_BRANCH"
88 # #Updating links in docs/conf.py
89 sed -i "s/latest/$stable_release_str/g" docs/conf.py
90 if [ "$PUBLISH" == "true" ]
93 echo "Update docs/conf.py links from latest to $stable_release_str"
94 git commit -s -m "Update docs/conf.py links from latest to $stable_release_str
96 Should be $stable_release_str on ${GERRIT_BRANCH}."