12a1409c1f910f62eccb6b0e43ad661a37ba98a2
[osm/devops.git] / tools / newtag.sh
1 #!/bin/bash
2 #
3 # Copyright 2020 ETSI
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 if [ $# -ne 5 ]; then
18 echo "Usage $0 <repo> <branch> <tag> <user> <release_name>"
19 echo "Example: $0 all master v4.0.2 garciadeblas FOUR"
20 echo "Example: $0 devops v5.0 v5.0.3 marchettim FIVE"
21 exit 1
22 fi
23
24 BRANCH="$2"
25 TAG="$3"
26 USER="$4"
27 RELEASE_NAME="$5"
28 tag_header="OSM Release $RELEASE_NAME:"
29 tag_message="$tag_header version $TAG"
30
31 modules="common devops IM LCM LW-UI MON N2VC NBI openvim osmclient RO vim-emu POL NG-UI"
32 list=""
33 for i in $modules; do
34 if [ "$1" == "$i" -o "$1" == "all" ]; then
35 list="$1"
36 break
37 fi
38 done
39
40 [ "$1" == "all" ] && list=$modules
41
42 if [ -z "$list" ]; then
43 echo "Repo must be one of these: $modules all"
44 exit 1
45 fi
46
47 for i in $list; do
48 echo $i
49 if [ ! -d $i ]; then
50 git clone ssh://$USER@osm.etsi.org:29418/osm/$i
51 fi
52 git -C $i checkout $BRANCH
53 git -C $i pull --rebase
54 git -C $i tag -a $TAG -m"$tag_message"
55 git -C $i push origin $TAG --follow-tags
56 sleep 2
57 done
58
59 exit 0