comparison seal-galaxy-cc1b1911/make_release.sh @ 0:244073d9abc1 draft default tip

Uploaded
author crs4
date Wed, 15 Oct 2014 09:41:10 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:244073d9abc1
1 #!/bin/bash
2
3 #set -x
4 set -o errexit
5 set -o nounset
6 set -o pipefail
7
8 PackageName="seal-galaxy"
9
10
11 function error() {
12 if [ $# -ge 1 ]; then
13 echo $* >&1
14 fi
15 exit 1
16 }
17
18 function usage_error() {
19 echo "Usage: $0 version"
20 echo "Specify version as a git revid (id or tag) for the Seal repository, and " >&2
21 echo "optionally a '-n' suffix for the wrapper version; e.g., 0.4.1, 0.4.1-1, 0.4.1-2" >&2
22 error
23 }
24
25 function confirm() {
26 local prompt="${1}"
27 echo "${prompt} [Y/n]"
28 read -p "Answer: " yn
29 case "${yn}" in
30 ''|[Yy]) # do nothing and keep going
31 ;;
32 [Nn]) echo "Aborting"; exit 0
33 ;;
34 *) usage_error "Unrecognized answer. Please specify Y or n"
35 ;;
36 esac
37 return 0
38 }
39
40 function rewrite_seal_version() {
41 local grep_expr='<package name="seal" version=".*">'
42 if ! grep "${grep_expr}" tool_dependencies.xml >/dev/null ; then
43 error "Couldn't find expected package line in tool_dependencies.xml"
44 fi
45
46 printf -v sed_expr1 '/<package name="seal"/s/version="[^"]*"/version="%s"/' "${seal_version}"
47 printf -v sed_expr2 '/<action type="shell_command">/s/git reset --hard \([^<]\+\)\s*/git reset --hard %s/' "${seal_version}"
48 sed -i -e "${sed_expr1}" -e "${sed_expr2}" tool_dependencies.xml
49 echo "Edited tool_dependencies.xml" >&2
50
51 # edit the tools as well
52 printf -v sed_expr3 '/<requirement type="package" version=.*>\s*seal\s*</s/version="[^"]\+"/version="%s"/' "${seal_version}"
53 printf -v sed_expr4 '/<tool id=/s/version="[^"]\+"/version="%s"/' "${seal_version}"
54 sed -i -e "${sed_expr3}" -e "${sed_expr4}" seal/*.xml
55
56 echo "Edited tool definitions" >&2
57 }
58
59 ############# main ###############3
60
61 if [ $# -eq 1 ]; then
62 wrapper_version="${1}"
63 else
64 usage_error
65 fi
66
67 echo "Will rewrite tool_dependencies.xml setting the the package version to '${wrapper_version}'."
68 confirm "Are you sure you want to proceed? [Y/n]"
69
70 # ensure the tag doesn't already exist
71 if git tag -l | grep -w "${wrapper_version}" ; then
72 error "A release tag called '${wrapper_version}' already exists"
73 fi
74
75 # remove the wrapper suffix, if it's there
76 seal_version=$(echo ${wrapper_version} | sed -e 's/-[^-]\+$//')
77 echo "Using seal version ${seal_version}"
78
79 rewrite_seal_version "${seal_version}"
80
81 git commit -a --allow-empty -m "Wrappers release for Seal '${seal_version}'"
82 git tag "${wrapper_version}"
83
84 revid=$(git rev-parse HEAD)
85
86 echo "Tagged new commit ${revid} with tag '${wrapper_version}'"
87
88 short_revid=${revid::8}
89 archive_name=${PackageName}-${short_revid}.tar.gz
90
91 git archive --format tar.gz --prefix ${PackageName}-${short_revid}/ HEAD -o "${archive_name}"
92
93 echo "Don't forget to upload the archive to the toolshed!"