]> gerrit.simantics Code Review - simantics/platform.git/blob - releng/doc/release-helper.sh
856182f223704973957a4e7ef887e6e7b8e072cc
[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 [ ! -d $version ]; then
118         echo "Version directory '$version' does not exist yet. Please run the 'clone' action first."
119         exit -1
120 fi
121
122 pushd $version > /dev/null
123 case "$action" in
124         branch)
125                 for (( i=0; i<${repositoryCount}; i++ )); do
126                         localPath lp $i
127                         msg $i "Create $branch branch in $lp"
128                         pushd $lp > /dev/null
129                         branch $branch
130                         popd > /dev/null
131                 done
132         ;;
133         checkout)
134                 for (( i=0; i<${repositoryCount}; i++ )); do
135                         localPath lp $i
136                         msg $i "Checkout $branch branch in $lp"
137                         pushd $lp > /dev/null
138                         checkout $branch
139                         popd > /dev/null
140                 done
141         ;;
142         tag)
143                 for (( i=0; i<${repositoryCount}; i++ )); do
144                         localPath lp $i
145                         msg $i "Tag ${version} for $lp"
146                         pushd $lp > /dev/null
147                         checkout $branch
148                         tag ${tagForVersion}
149                         popd > /dev/null
150                 done
151         ;;
152         list-branches)
153                 for (( i=0; i<${repositoryCount}; i++ )); do
154                         localPath lp $i
155                         msg $i "List branches in $lp"
156                         pushd $lp > /dev/null
157                         listBranches
158                         popd > /dev/null
159                 done
160         ;;
161         list-tags)
162                 for (( i=0; i<${repositoryCount}; i++ )); do
163                         localPath lp $i
164                         msg $i "List tags in $lp"
165                         pushd $lp > /dev/null
166                         listTags
167                         popd > /dev/null
168                 done
169         ;;
170         remove-tag)
171                 for (( i=0; i<${repositoryCount}; i++ )); do
172                         localPath lp $i
173                         msg $i "Remove tag $tagForVersion from $lp"
174                         pushd $lp > /dev/null
175                         removeTag ${tagForVersion}
176                         popd > /dev/null
177                 done
178         ;;
179         fetch)
180                 for (( i=0; i<${repositoryCount}; i++ )); do
181                         localPath lp $i
182                         msg $i "Fetch from remote origin in $lp"
183                         pushd $lp > /dev/null
184                         fetch
185                         popd > /dev/null
186                 done
187         ;;
188         pull)
189                 for (( i=0; i<${repositoryCount}; i++ )); do
190                         localPath lp $i
191                         msg $i "Pull from remote origin in $lp"
192                         pushd $lp > /dev/null
193                         pull
194                         popd > /dev/null
195                 done
196         ;;
197         push)
198                 for (( i=0; i<${repositoryCount}; i++ )); do
199                         localPath lp $i
200                         msg $i "Push branch $branch to remote origin in $lp"
201                         pushd $lp > /dev/null
202                         pushBranch $branch
203                         popd > /dev/null
204                 done
205         ;;
206         push-tags)
207                 for (( i=0; i<${repositoryCount}; i++ )); do
208                         localPath lp $i
209                         msg $i "Push tags to remote origin in $lp"
210                         pushd $lp > /dev/null
211                         pushTags
212                         popd > /dev/null
213                 done
214         ;;
215         status)
216                 for (( i=0; i<${repositoryCount}; i++ )); do
217                         localPath lp $i
218                         msg $i "Status of $lp"
219                         pushd $lp > /dev/null
220                         status
221                         popd > /dev/null
222                 done
223         ;;
224         *)
225                 echo "Usage: ${self} <version> <branch-name> <user-name> clone|branch|checkout|fetch|list-tags|pull|push|push-tags|remove-tag|status|tag"
226
227         ;;
228 esac