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