try to make release.sh support version-only tags.
[xorg-util-modular.git] / release.sh
blob0383a12bb90d1a44b0ab0e8efb2cfea59149affe
1 #!/bin/sh
3 set -e
5 announce_list="xorg-announce@lists.freedesktop.org"
6 xorg_list="xorg@lists.freedesktop.org"
7 dri_list="dri@lists.freedesktop.org"
8 host_people=annarchy.freedesktop.org
9 host_xorg=xorg.freedesktop.org
10 host_dri=dri.freedesktop.org
11 user=`whoami`
13 usage()
15 cat <<HELP
16 Usage: `basename $0` [options] <section> <tag_previous> <tag_current>
18 Options:
19 --force force overwritting an existing release
20 --user <name> username on $host_people (default "`whoami`")
21 --help this help message
22 HELP
25 gen_announce_mail()
27 case "$tag_previous" in
28 initial)
29 range="$tag_current"
32 range="$tag_previous".."$tag_current"
34 esac
36 MD5SUM=`which md5sum || which gmd5sum`
37 SHA1SUM=`which sha1sum || which gsha1sum`
39 if [ $section = libdrm ]; then
40 host=$host_dri
41 list=$dri_list
42 else
43 host=$host_xorg
44 list=$xorg_list
47 cat <<RELEASE
48 Subject: [ANNOUNCE] $module $version
49 To: $announce_list
50 CC: $list
52 `git log --no-merges "$range" | git shortlog`
54 git tag: $tag_current
56 http://$host/$section_path/$tarbz2
57 MD5: `cd $tarball_dir && $MD5SUM $tarbz2`
58 SHA1: `cd $tarball_dir && $SHA1SUM $tarbz2`
60 http://$host/$section_path/$targz
61 MD5: `cd $tarball_dir && $MD5SUM $targz`
62 SHA1: `cd $tarball_dir && $SHA1SUM $targz`
64 RELEASE
67 export LC_ALL=C
69 while [ $# != 0 ]; do
70 case "$1" in
71 --force)
72 force="yes"
73 shift
75 --help)
76 usage
77 exit 0
79 --user)
80 shift
81 user=$1
82 shift
84 --*)
85 echo "error: unknown option"
86 usage
87 exit 1
90 section="$1"
91 tag_previous="$2"
92 tag_current="$3"
93 shift 3
94 if [ $# != 0 ]; then
95 echo "error: unknown parameter"
96 usage
97 exit 1
100 esac
101 done
103 tarball_dir="$(dirname $(find . -name config.status))"
104 module="${tag_current%-*}"
105 if [ "x$module" = "x$tag_current" ]; then
106 # version-number-only tag.
107 pwd=`pwd`
108 module=`basename $pwd`
109 version="$tag_current"
110 else
111 # module-and-version style tag
112 version="${tag_current##*-}"
115 modulever=$module-$version
116 tarbz2="$modulever.tar.bz2"
117 targz="$modulever.tar.gz"
118 announce="$tarball_dir/$modulever.announce"
120 echo "checking parameters"
121 if ! [ -f "$tarball_dir/$tarbz2" ] ||
122 ! [ -f "$tarball_dir/$targz" ] ||
123 [ -z "$tag_previous" ] ||
124 [ -z "$section" ]; then
125 echo "error: incorrect parameters!"
126 usage
127 exit 1
130 if [ "$section" = "libdrm" ]; then
131 section_path="libdrm"
132 srv_path="/srv/$host_dri/www/$section_path"
133 else
134 section_path="archive/individual/$section"
135 srv_path="/srv/$host_xorg/$section_path"
138 echo "checking for proper current dir"
139 if ! [ -d .git ]; then
140 echo "error: do this from your git dir, weenie"
141 exit 1
144 echo "checking for an existing tag"
145 if ! git tag -l $tag_current >/dev/null; then
146 echo "error: you must tag your release first!"
147 exit 1
150 echo "checking for an existing release"
151 if ssh $user@$host_people ls $srv_path/$targz >/dev/null 2>&1 ||
152 ssh $user@$host_people ls $srv_path/$tarbz2 >/dev/null 2>&1; then
153 if [ "x$force" = "xyes" ]; then
154 echo "warning: overriding released file ... here be dragons."
155 else
156 echo "error: file already exists!"
157 exit 1
161 echo "generating announce mail template, remember to sign it"
162 gen_announce_mail >$announce
163 echo " at: $announce"
165 echo "installing release into server"
166 scp $tarball_dir/$targz $tarball_dir/$tarbz2 $user@$host_people:$srv_path
168 echo "pushing changes upstream"
169 git push origin
170 git push origin $tag_current