Update stable/magnesium links
[docs.git] / update_docs_version.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 <path_to_autorelease> <release_name> <branch_name> <publish>"
14     echo ""
15     echo "    path_to_autorelease:  The path to the autorelease"
16     echo "    release_name:  The release_name e.g Magnesium ."
17     echo "    branch_name:  Name of the branch to be updated e.g stable/sodium."
18     echo "    publish:  Set to true to publish"
19     echo ""
20 }
21 while getopts :h: opts; do
22   case "$opts" in
23     h)
24         update_file_usage
25         exit 0
26         ;;
27     [?])
28         update_file_usage
29         exit 1
30         ;;
31   esac
32 done
33
34 # User input
35 path_to_autorelease="$1"
36 release_name="$2"
37 # Captilize Version Name
38 release_name="$(tr '[:lower:]' '[:upper:]' <<< "${release_name:0:1}")${release_name:1}"
39 branch_name="$3"
40 publish="$4"
41
42 ################
43 # Start script #
44 ###############
45 cd "$path_to_autorelease"/ || exit
46 git submodule update
47
48 #'|| true' for repo like serviceutils where docs/conf.yaml doesn't exist
49 command='sed -i ''"s/.*version.*/version: '"$release_name"'/"'' docs/conf.yaml || true'
50 git submodule foreach "git checkout $branch_name"
51 git submodule foreach "$command"
52 if [ "$publish" == "true" ]
53   then
54     git submodule foreach "git add . || true"
55     git submodule foreach "git commit -s -m 'Update docs header to $release_name in $branch_name
56
57 Should be $release_name on $branch_name.' || true"
58     git submodule foreach "git review || true"
59 fi