]> gerrit.simantics Code Review - simantics/platform.git/blob - releng/doc/release-helper.sh
Helper script for doing release train related project branching and tagging.
[simantics/platform.git] / releng / doc / release-helper.sh
1 #!/bin/bash
2
3 self=`basename $0`
4 version=$1
5 branch=$2
6 user=$3
7 action=$4
8 tagForVersion=v${version}
9
10 ###############################################################################
11
12 declare -a repositories=(
13    "simantics/third-party.git" "third-party"
14    "simantics/platform.git" "platform"
15    "simantics/fmil.git" "fmil"
16    "simantics/interop.git" "interop"
17    "simantics/district.git" "district"
18    "simantics/matlab.git" "matlab"
19    "simantics/python.git" "python"
20    "simantics/r.git" "r"
21    "simantics/sysdyn.git" "sysdyn"
22    "members/fmi.git" "fmi"
23    "members/simupedia.git" "simupedia"
24 )
25
26 repositoryCount=$((${#repositories[@]} / 2))
27
28 function repo {
29         eval $1=\${repositories[$(($2 * 2))]}
30 }
31
32 function localPath {
33         eval $1=\${repositories[$(($2 * 2 + 1))]}
34 }
35
36 ###############################################################################
37
38 function msg {
39         echo "[$(($1+1))/${repositoryCount}] $2"
40 }
41
42 function clone {
43         echo "git clone ssh://${user}@www.simantics.org:29418/$1"
44         git clone ssh://${user}@www.simantics.org:29418/$1
45 }
46
47 function branch {
48         echo "git branch $1"
49         git branch $1
50 }
51
52 function fetch {
53         echo "git fetch --all"
54         git fetch --all
55 }
56
57 function pull {
58         echo "git pull --all"
59         git pull --all
60 }
61
62 function pushBranch {
63         echo "git push origin $1"
64         git push origin $1
65 }
66
67 function checkout {
68         echo "git checkout $1"
69         git checkout $1
70 }
71
72 function tag {
73         echo "git tag $1 -m \"Simantics $1 simultaneous release\""
74         git tag $1 -m "Simantics $1 simultaneous release"
75 }
76
77 function removeTag {
78         echo "git tag -d $1"
79         git tag -d $1
80 }
81
82 function pushTags {
83         echo "git push origin --tags"
84         git push origin --tags
85 }
86
87 function status {
88         git status
89 }
90
91 function listTags {
92         git tag -l
93 }
94
95 function listBranches {
96         git branch -a
97 }
98
99 ###############################################################################
100
101 case "$action" in
102         clone)
103                 mkdir -p $version
104                 pushd $version > /dev/null
105                 for (( i=0; i<${repositoryCount}; i++ )); do
106                         repo p $i
107                         msg $i "Clone $p"
108                         clone $p
109                 done
110                 popd > /dev/null
111                 exit 0
112         ;;
113 esac
114
115 pushd $version > /dev/null
116 case "$action" in
117         branch)
118                 for (( i=0; i<${repositoryCount}; i++ )); do
119                         localPath lp $i
120                         msg $i "Create $branch branch in $lp"
121                         pushd $lp > /dev/null
122                         branch $branch
123                         popd > /dev/null
124                 done
125         ;;
126         checkout)
127                 for (( i=0; i<${repositoryCount}; i++ )); do
128                         localPath lp $i
129                         msg $i "Checkout $branch branch in $lp"
130                         pushd $lp > /dev/null
131                         checkout $branch
132                         popd > /dev/null
133                 done
134         ;;
135         tag)
136                 for (( i=0; i<${repositoryCount}; i++ )); do
137                         localPath lp $i
138                         msg $i "Tag ${version} for $lp"
139                         pushd $lp > /dev/null
140                         checkout $branch
141                         tag ${tagForVersion}
142                         popd > /dev/null
143                 done
144         ;;
145         list-branches)
146                 for (( i=0; i<${repositoryCount}; i++ )); do
147                         localPath lp $i
148                         msg $i "List branches in $lp"
149                         pushd $lp > /dev/null
150                         listBranches
151                         popd > /dev/null
152                 done
153         ;;
154         list-tags)
155                 for (( i=0; i<${repositoryCount}; i++ )); do
156                         localPath lp $i
157                         msg $i "List tags in $lp"
158                         pushd $lp > /dev/null
159                         listTags
160                         popd > /dev/null
161                 done
162         ;;
163         remove-tag)
164                 for (( i=0; i<${repositoryCount}; i++ )); do
165                         localPath lp $i
166                         msg $i "Remove tag $tagForVersion from $lp"
167                         pushd $lp > /dev/null
168                         removeTag ${tagForVersion}
169                         popd > /dev/null
170                 done
171         ;;
172         fetch)
173                 for (( i=0; i<${repositoryCount}; i++ )); do
174                         localPath lp $i
175                         msg $i "Fetch from remote origin in $lp"
176                         pushd $lp > /dev/null
177                         fetch
178                         popd > /dev/null
179                 done
180         ;;
181         pull)
182                 for (( i=0; i<${repositoryCount}; i++ )); do
183                         localPath lp $i
184                         msg $i "Pull from remote origin in $lp"
185                         pushd $lp > /dev/null
186                         pull
187                         popd > /dev/null
188                 done
189         ;;
190         push)
191                 for (( i=0; i<${repositoryCount}; i++ )); do
192                         localPath lp $i
193                         msg $i "Push branch $branch to remote origin in $lp"
194                         pushd $lp > /dev/null
195                         pushBranch $branch
196                         popd > /dev/null
197                 done
198         ;;
199         push-tags)
200                 for (( i=0; i<${repositoryCount}; i++ )); do
201                         localPath lp $i
202                         msg $i "Push tags to remote origin in $lp"
203                         pushd $lp > /dev/null
204                         pushTags
205                         popd > /dev/null
206                 done
207         ;;
208         status)
209                 for (( i=0; i<${repositoryCount}; i++ )); do
210                         localPath lp $i
211                         msg $i "Status of $lp"
212                         pushd $lp > /dev/null
213                         status
214                         popd > /dev/null
215                 done
216         ;;
217         *)
218                 echo "Usage: ${self} <version> <branch-name> <user-name> clone|branch|checkout|fetch|list-tags|pull|push|push-tags|remove-tag|status|tag"
219
220         ;;
221 esac