9dad0ec5c800850c70f9b033a865282965be1443
[releng/builder.git] / jjb / docs / docs_version_bump_projects.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2019 The Linux Foundation and others.
5 #
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 ##############################################################################
11
12 update_file_usage () {
13     echo "Usage: $0 <release_name> <PUBLISH>"
14     echo ""
15     echo "    release_name:  The release_name e.g Chlorine, Argon."
16     echo "    PUBLISH:  Set to true to PUBLISH"
17     echo ""
18 }
19 while getopts :h: opts; do
20   case "$opts" in
21     h)
22         update_file_usage
23         exit 0
24         ;;
25     [?])
26         update_file_usage
27         exit 1
28         ;;
29   esac
30 done
31
32 # shellcheck disable=SC1090
33 . ~/lf-env.sh
34
35 lf-activate-venv --python python3 "git-review==2.3.1"
36
37 # Workaround for git-review failing to copy the commit-msg hook to submodules
38 git config core.hooksPath "$(git rev-parse --show-toplevel)/.git/hooks"
39
40 git config --global --add gitreview.username "jenkins-$SILO"
41 cd "$WORKSPACE"/autorelease || exit
42 GERRIT_PROJECT="releng/autorelease"
43 if [ "$GERRIT_PROJECT" == "releng/autorelease" ]; then
44     # User input
45     RELEASE_NAME=${RELEASE_NAME:-}
46     # Captilize Version Name
47     release_name="$(tr '[:lower:]' '[:upper:]' <<< "${RELEASE_NAME:0:1}")${RELEASE_NAME:1}"
48     echo "Start Version Updating in odl-projects"
49     echo "RELEASE_NAME : $release_name"
50     ################
51     # Start script #
52     ###############
53     git submodule update
54     #'|| true' for repo like serviceutils where docs/conf.yaml doesn't exist
55     command='sed -i ''"s/.*version.*/version: '"$release_name"'/"'' docs/conf.yaml || true'
56     git submodule foreach "git checkout $GERRIT_BRANCH"
57     echo "git checkout $GERRIT_BRANCH"
58     git submodule foreach "git branch"
59     git submodule foreach "$command"
60     # Workaround for git-review failing to copy the commit-msg hook to submodules
61     # git submodule foreach 'git config core.hooksPath "$(git rev-parse --show-toplevel)/.git/hooks"'
62     if [ "$PUBLISH" == "true" ]
63       then
64         echo "Update docs header to $release_name in $STREAM"
65         git submodule foreach "git add . || true"
66         git submodule foreach "git commit -s -m 'Update docs header to $release_name in $STREAM
67
68     Should be $release_name on $STREAM.' || true"
69         git submodule foreach "git review || true"
70     fi
71 fi