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