3 # Release management script for Wire Cell Toolkit.
5 # Note, this is meant to create and operate on a throw-away source
6 # area. Do NOT use this on real working areas. Do NOT reuse this on
7 # areas used for past releases. If you do, all that you love will be
8 # torn and rent asunder and laid waste.
10 # 1) Create release source area. This leaves the main repo and each
11 # submodule sitting at the tip of the given branch. This has many
12 # steps which can also be done individually. Warning: this hard-codes
13 # a list of submodules to purge out of the release so edit it in
14 # master before staring a release..
16 # $ ./make-release.sh bring-forward 0.5.x
18 # 2) If the master tips of each submodule are what is needed then tag
19 # everything and make a top level commit. Note, this commit is not
20 # pushed. Note: the source area is left in a slightly inconsistent
21 # state in that the submodule URLs are changed to HTTPS but no "git
22 # submodule sysnc" is done. This is so the push step can still go via
25 # $ ./make-release.sh apply-tags 0.5.x 0.5.0 "Some useful one liner describing major changes."
27 # 3) If happy, push all the changes
29 # $ ./make-release.sh push-everything 0.5.x
36 local target=$1 ; shift
37 if [ -d "$target" ] ; then
38 echo "source target exists in: $target"
41 git clone git@github.com:WireCell/wire-cell-build.git $target
46 local dir=${1?no directory given} ; shift
47 if [ ! -d $dir ] ; then
48 echo "No such directory: $dir"
60 local branch=${1?must provide branch} ; shift
63 if [ -n "$(git show-ref refs/heads/$branch)" ] ; then
64 echo "Already have local: $branch"
66 elif [ -n "$(git show-ref remotes/origin/$branch)" ] ; then
67 echo "Branch on origin: $branch"
68 git checkout -b $branch origin/$branch
70 echo "Initial creation of branch: $branch"
71 git checkout -b $branch origin/master
76 function purge-submodules
78 local branch=${1?must provide branch} ; shift
82 for sm in $submodules ; do
84 git submodule deinit $sm || exit 1
90 # alg bio dfp rio riodata rootdict rootvis tbb
92 function branch-submodules
94 local branch=${1?must provide branch} ; shift
97 git submodule init || exit 1
98 git submodule update || exit 1
100 git submodule foreach "git checkout $branch || git checkout -b $branch --track origin/master"
105 function update-submodules
107 local branch=${1?must provide branch} ; shift
109 git pull --recurse-submodules
113 function fix-dotgitmodules
115 local branch=${1?must provide branch} ; shift
118 local dev_url="git@github.com:$org"
119 local usr_url="https://github.com/$org"
123 # move to anon-friend URL for releases
124 sed -i -e 's|'$dev_url'|'$usr_url'|'g .gitmodules
126 # Crazy hack to make sure .gitmodules is updated with new branch
127 # for each surviving submodule. There is probably a better way to
129 git submodule foreach 'branch="$(git --git-dir=../.git rev-parse --abbrev-ref HEAD)"; sm="$(basename $(pwd))"; git config -f ../.gitmodules submodule.$sm.branch $branch'
131 # Do NOT actually sync
138 # kitchen sink function
139 function bring-forward
141 local branch=${1?must give branch} ; shift
143 echo -e "\ngetting source\n"
144 get-source $branch || exit 1
146 echo -e "\nmaking top branch\n"
147 make-branch $branch ||exit 1
149 unwanted_submodules="alg bio dfp rio riodata rootdict rootvis tbb"
150 echo -e "\npurging submodules: $unwanted_submodules\n"
151 purge-submodules $branch $unwanted_submodules
153 echo -e "\nbranching submodules\n"
154 branch-submodules $branch
156 echo -e "\nupdating submodules\n"
157 update-submodules $branch
159 echo -e "\nswitch submodule URLs\n"
160 fix-dotgitmodules $branch
163 # fixme: specify which submodules to keep, purge all others
164 # fixme bonus1: hard code some (waftools, util, iface)
165 # fixme bonus2: figure out dependencies!
168 # now do tag-submodules, push-submodules, submodule-urls, push-main
170 function apply-submodule-tags
172 local branch=${1?must provide branch} ; shift
173 local tag=${1?must give branch} ; shift
177 git submodule foreach git tag -a -m "$message" $tag
182 function commit-tag-main
184 local branch=${1?must provide branch} ; shift
185 local tag=${1?must give branch} ; shift
186 local message=${1?must give message} ; shift
189 git commit -a -m "$message"
190 git tag -a -m "$message" "$tag"
193 # now by hand: git push origin $branch
196 # kitchen sink function
199 local branch=${1?must provide branch} ; shift
200 local tag=${1?must give tag} ; shift
203 echo -e "\napplying submodule tags\n"
204 apply-submodule-tags $branch $tag "$message"
206 echo -e "\ncommitting and tagging top\n"
207 commit-tag-main $branch $tag "$message"
212 # warning this pushes!
213 function push-everything
215 local branch=${1?must provide source directory aka branch} ; shift
218 git submodule foreach git push origin $branch
219 git submodule foreach git push --tags
221 git push origin $branch
229 local branch=${1?must give branch} ; shift
230 local tag=${1?must give tag} ; shift
231 local base=${1:-wire-cell-toolkit} ; shift
232 local name="${base}-${tag}"
233 local tarfile="${name}.tar.gz"
235 if [ -f "$tarfile" ] ; then
236 echo "target tarball file exists, remove to continue: $tarfile"
239 if [ -f "$name" ] ; then
240 echo "target directory exists, remove to continue: $name"
244 git clone --recurse-submodules --branch=$branch \
245 git@github.com:WireCell/wire-cell-build.git \
254 tar --exclude=.git* -czf $tarfile $name
257 echo "cp $tarfile /var/www/lar/software/releases"