9b407657ffd41da1aa336d925235b5dd5f635774
[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
18 if [ $# -ne 5 ]; then
19 echo "Usage $0 <repo> <branch> <tag> <user> <release_name>"
20 echo "Example: $0 all master v4.0.2 garciadeblas FOUR"
21 echo "Example: $0 devops v5.0 v5.0.3 marchettim FIVE"
22 exit 1
23 fi
24
25 BRANCH="$2"
26 TAG="$3"
27 USER="$4"
28 RELEASE_NAME="$5"
29 tag_header="OSM Release $RELEASE_NAME:"
30 tag_message="$tag_header version $TAG"
31
32 modules="common devops IM LCM MON N2VC NBI osmclient RO POL NG-UI PLA"
33 list=""
34 for i in $modules; do
35 if [ "$1" == "$i" -o "$1" == "all" ]; then
36 list="$1"
37 break
38 fi
39 done
40
41 [ "$1" == "all" ] && list=$modules
42
43 if [ -z "$list" ]; then
44 echo "Repo must be one of these: $modules all"
45 exit 1
46 fi
47
48 for i in $list; do
49 echo $i
50 if [ ! -d $i ]; then
51 git clone ssh://$USER@osm.etsi.org:29418/osm/$i
52 fi
53 git -C $i checkout $BRANCH || ! echo "$BRANCH was not found in $i repo" || continue
54 git -C $i pull --rebase
55 echo "Creating new tag $TAG in repo $i associated to branch $BRANCH"
56 git -C $i tag -a $TAG -m"$tag_message"
57 git -C $i push origin $TAG --follow-tags
58 sleep 2
59 done
60
61 exit 0