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