Multiple reader thread support for db client
[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    "simantics/3d.git" "3d"
23    "members/fmi.git" "fmi"
24    "members/simupedia.git" "simupedia"
25    "gold-members/proteus.git" "proteus"
26 )
27
28 repositoryCount=$((${#repositories[@]} / 2))
29
30 function repo {
31         eval $1=\${repositories[$(($2 * 2))]}
32 }
33
34 function localPath {
35         eval $1=\${repositories[$(($2 * 2 + 1))]}
36 }
37
38 ###############################################################################
39
40 function msg {
41         echo "[$(($1+1))/${repositoryCount}] $2"
42 }
43
44 function clone {
45         echo "git clone ssh://${user}@www.simantics.org:29418/$1"
46         git clone ssh://${user}@www.simantics.org:29418/$1
47 }
48
49 function branch {
50         echo "git branch $1"
51         git branch $1
52 }
53
54 function fetch {
55         echo "git fetch --all"
56         git fetch --all
57 }
58
59 function pull {
60         echo "git pull --all"
61         git pull --all
62 }
63
64 function pushBranch {
65         echo "git push origin $1"
66         git push origin $1
67 }
68
69 function checkout {
70         echo "git checkout $1"
71         git checkout $1
72 }
73
74 function tag {
75         echo "git tag $1 -m \"Simantics $1 simultaneous release\""
76         git tag $1 -m "Simantics $1 simultaneous release"
77 }
78
79 function removeTag {
80         echo "git tag -d $1"
81         git tag -d $1
82 }
83
84 function pushTags {
85         echo "git push origin --tags"
86         git push origin --tags
87 }
88
89 function status {
90         git status
91 }
92
93 function listTags {
94         git tag -l
95 }
96
97 function listBranches {
98         git branch -a
99 }
100
101 ###############################################################################
102
103 case "$action" in
104         clone)
105                 mkdir -p $version
106                 pushd $version > /dev/null
107                 for (( i=0; i<${repositoryCount}; i++ )); do
108                         repo p $i
109                         msg $i "Clone $p"
110                         clone $p
111                 done
112                 popd > /dev/null
113                 exit 0
114         ;;
115 esac
116
117 if [ -n "$version" ] && [ -d $version ]; then
118         pushd $version > /dev/null
119 fi
120
121 case "$action" in
122         branch)
123                 for (( i=0; i<${repositoryCount}; i++ )); do
124                         localPath lp $i
125                         msg $i "Create $branch branch in $lp"
126                         pushd $lp > /dev/null
127                         branch $branch
128                         popd > /dev/null
129                 done
130         ;;
131         checkout)
132                 for (( i=0; i<${repositoryCount}; i++ )); do
133                         localPath lp $i
134                         msg $i "Checkout $branch branch in $lp"
135                         pushd $lp > /dev/null
136                         checkout $branch
137                         popd > /dev/null
138                 done
139         ;;
140         tag)
141                 for (( i=0; i<${repositoryCount}; i++ )); do
142                         localPath lp $i
143                         msg $i "Tag ${version} for $lp"
144                         pushd $lp > /dev/null
145                         checkout $branch
146                         tag ${tagForVersion}
147                         popd > /dev/null
148                 done
149         ;;
150         list-branches)
151                 for (( i=0; i<${repositoryCount}; i++ )); do
152                         localPath lp $i
153                         msg $i "List branches in $lp"
154                         pushd $lp > /dev/null
155                         listBranches
156                         popd > /dev/null
157                 done
158         ;;
159         list-tags)
160                 for (( i=0; i<${repositoryCount}; i++ )); do
161                         localPath lp $i
162                         msg $i "List tags in $lp"
163                         pushd $lp > /dev/null
164                         listTags
165                         popd > /dev/null
166                 done
167         ;;
168         remove-tag)
169                 for (( i=0; i<${repositoryCount}; i++ )); do
170                         localPath lp $i
171                         msg $i "Remove tag $tagForVersion from $lp"
172                         pushd $lp > /dev/null
173                         removeTag ${tagForVersion}
174                         popd > /dev/null
175                 done
176         ;;
177         fetch)
178                 for (( i=0; i<${repositoryCount}; i++ )); do
179                         localPath lp $i
180                         msg $i "Fetch from remote origin in $lp"
181                         pushd $lp > /dev/null
182                         fetch
183                         popd > /dev/null
184                 done
185         ;;
186         pull)
187                 for (( i=0; i<${repositoryCount}; i++ )); do
188                         localPath lp $i
189                         msg $i "Pull from remote origin in $lp"
190                         pushd $lp > /dev/null
191                         pull
192                         popd > /dev/null
193                 done
194         ;;
195         push)
196                 for (( i=0; i<${repositoryCount}; i++ )); do
197                         localPath lp $i
198                         msg $i "Push branch $branch to remote origin in $lp"
199                         pushd $lp > /dev/null
200                         pushBranch $branch
201                         popd > /dev/null
202                 done
203         ;;
204         push-tags)
205                 for (( i=0; i<${repositoryCount}; i++ )); do
206                         localPath lp $i
207                         msg $i "Push tags to remote origin in $lp"
208                         pushd $lp > /dev/null
209                         pushTags
210                         popd > /dev/null
211                 done
212         ;;
213         status)
214                 for (( i=0; i<${repositoryCount}; i++ )); do
215                         localPath lp $i
216                         msg $i "Status of $lp"
217                         pushd $lp > /dev/null
218                         status
219                         popd > /dev/null
220                 done
221         ;;
222         *)
223                 echo "Usage: ${self} <version> <branch-name> <user-name> clone|branch|checkout|fetch|list-tags|pull|push|push-tags|remove-tag|status|tag"
224                 if [ -d $version ]; then
225                         echo "Version directory ('$version') does not exist yet. Please run the 'clone' action first."
226                 fi
227
228         ;;
229 esac