formats: clarify setting of reverse_bytes
[sox.git] / release.sh
blob5aeaa4bcb287a69fd406f2f2c767220198e1f5f1
1 #!/bin/sh
3 # Before a release:
4 # * Update configure.ac and possibly ChangeLog and
5 # src/sox.h (SOX_LIB_VERSION_CODE) to match release #. If this is a
6 # release candidate, add "rcN" to end of version in configure.ac.
7 # * Update date strings and possibly copyright years in man pages.
8 # * Tag files to release using following form: git tag sox-14.4.0rc1
10 # Automatable release steps. Most are optional but default to enabled.
12 # 1. Verify master git repo matches local git repo.
13 # 2. Build source packages.
14 # 3. Build Windows packages.
15 # 4. Generate announce email from NEWS file.
16 # 5. Build HTML and PDF documentation and upload to web site.
17 # 6. Create new release directory and upload packages to directory.
19 # After a release:
20 # * Make sure local tags get pushed remotely: git push --tags
21 # * Need to update sourceforge for recommended package to give to each
22 # OS.
23 # * send announcement email using Mutt or similar (mutt -H sox-RELEASE.email).
24 # * Update front page of web site to point to latest files and give
25 # latest news.
26 # * Modify configure.ac, increment version # and put "git" at end of #.
29 usage()
31 cat <<HELP
32 Usage: `basename $0` [options] <tag_previous> <tag_current>
34 <tag_previous> can be special value "initial" when ran for first
35 time.
37 Options:
38 --force force overwritting an existing release
39 --help this help message
40 --ignore-local-changes don't abort on uncommitted local changes
41 --no-build Skip building executable packages
42 --no-release Skip releasing files.
43 --no-short-log Put NEWS content into email instead of autogenerate.
44 --remote git remote where the change should be pushed (default "origin")
45 --user <name> username on $hostname
46 HELP
49 build_files=yes
50 update_web=yes
51 release_files=yes
52 ignore_changes=no
53 short_log=yes
54 user=$USER
55 remote=origin
56 module="sox"
57 webpath="sourceforge.net/projects/sox/files"
58 rcpath=""
59 email_list="sox-users@lists.sourceforge.net,sox-devel@lists.sourceforge.net"
60 hostname="shell.sourceforge.net"
61 release_path="/home/frs/project/sox"
62 release_force="no"
63 web_path="/home/project-web/sox/htdocs"
66 while [ $# != 0 ]; do
67 case "$1" in
68 --force)
69 release_force="yes"
70 shift
72 --help)
73 usage
74 exit 0
76 --ignore-local-changes)
77 ignore_changes=yes
78 shift
80 --no-build)
81 build_files=no
82 shift
84 --no-release)
85 release_files=no
86 shift
88 --no-short-log)
89 short_log=no
90 shift
92 --remote)
93 shift
94 remote=$1
95 shift
97 --user)
98 shift
99 user=$1
100 shift
102 --*)
103 echo "error: unknown option"
104 usage
105 exit 1
108 tag_previous="$1"
109 tag_current="$2"
110 shift 2
111 if [ $# != 0 ]; then
112 echo "error: unknown parameter"
113 usage
114 exit 1
117 esac
118 done
120 # configure must have been ran to get release #.
121 [ ! -x configure ] && autoreconf -i
122 [ ! -f Makefile ] && ./configure
124 # Check if the object has been pushed. Do do so
125 # 1. Check if the current branch has the object. If not, abort.
126 # 2. Check if the object is on $remote/branchname. If not, abort.
127 local_sha=`git rev-list -1 $tag_current`
128 current_branch=`git branch | grep "\*" | sed -e "s/\* //"`
129 set +e
130 git rev-list $current_branch | grep $local_sha > /dev/null
131 if [ $? -eq 1 ]; then
132 echo "Cannot find tag '$tag_current' on current branch. Aborting."
133 echo "Switch to the correct branch and re-run the script."
134 exit 1
137 revs=`git rev-list $remote/$current_branch..$current_branch | wc -l`
138 if [ $revs -ne 0 ]; then
139 git rev-list $remote/$current_branch..$current_branch | grep $local_sha > /dev/null
141 if [ $? -ne 1 ]; then
142 echo "$remote/$current_branch doesn't have object $local_sha"
143 echo "for tag '$tag_current'. Did you push branch first? Aborting."
144 exit 1
147 set -e
149 module="${tag_current%-*}"
150 if [ "x$module" = "x$tag_current" ]; then
151 # release-number-only tag.
152 pwd=`pwd`
153 module=`basename $pwd`
154 release_num="$tag_current"
155 else
156 # module-and-release-number style tag
157 release_num="${tag_current##*-}"
160 detected_module=`grep 'PACKAGE = ' Makefile | sed 's|PACKAGE = ||'`
161 if [ -f $detected_module-$release_num.tar.bz2 ]; then
162 module=$detected_module
165 osx_zip="$module-${release_num}-macosx.zip"
166 win_zip="$module-${release_num}-win32.zip"
167 win_exe="$module-${release_num}-win32.exe"
168 src_gz="$module-${release_num}.tar.gz"
169 src_bz2="$module-${release_num}.tar.bz2"
170 release_list="$src_gz $src_bz2 $win_exe $win_zip $osx_zip"
172 email_file="${module}-${release_num}.email"
174 build()
176 echo "Creating source packages..."
177 ! make -s distcheck && echo "distcheck failed" && exit 1
178 ! make -s dist-bzip2 && echo "dist-bzip2 failed" && exit 1
180 if [ $update_web = "yes" ]; then
181 echo "Creating HTML documentation for web site..."
182 ! make -s html && echo "html failed" && exit 1
184 echo "Creating PDF documentation for web site..."
185 ! make -s pdf && echo "pdf failed" && exit 1
188 echo "Creating Windows packages..."
189 make -s distclean
190 rm -f $win_zip
191 rm -f $win_exe
192 ./mingwbuild
195 MD5SUM=`which md5sum || which gmd5sum`
196 SHA1SUM=`which sha1sum || which gsha1sum`
198 create_email()
200 cat<<EMAIL_HEADER
201 Subject: [ANNOUNCE] SoX ${release_num} Released
202 To: ${email_list}
204 The developers of SoX are happy to announce the release of SoX ${release_num}.
205 Thanks to all who contributed to this release.
207 EMAIL_HEADER
209 if [ $short_log = "yes" ]; then
210 case "$tag_previous" in
211 initial)
212 range="$tag_current"
215 range="$tag_previous".."$tag_current"
217 esac
218 echo "git tag: $tag_current"
219 echo
220 git log --no-merges "$range" | git shortlog
221 else
222 cat NEWS
225 cat<<EMAIL_FOOTER
227 http://$webpath/${rcpath}${module}/$release_num/$osx_zip/download
229 MD5: `$MD5SUM $osx_zip`
230 SHA1: `$SHA1SUM $osx_zip`
232 http://$webpath/${rcpath}${module}/$release_num/$win_exe/download
234 MD5: `$MD5SUM $win_exe`
235 SHA1: `$SHA1SUM $win_exe`
237 http://$webpath/${rcpath}${module}/$release_num/$win_zip/download
239 MD5: `$MD5SUM $win_zip`
240 SHA1: `$SHA1SUM $win_zip`
242 http://$webpath/${rcpath}${module}/$release_num/$src_bz2/download
244 MD5: `$MD5SUM $src_bz2`
245 SHA1: `$SHA1SUM $src_bz2`
247 http://$webpath/${rcpath}${module}/$release_num/$src_gz/download
249 MD5: `$MD5SUM $src_gz`
250 SHA1: `$SHA1SUM $src_gz`
252 EMAIL_FOOTER
255 case $release_num in
256 *git)
257 echo "Aborting. Should not release untracked version number."
258 exit 1
260 *rc?|*rc??)
261 echo "Release candidate detected. Disabling web update."
262 update_web=no
263 rcpath="release_candidates/"
265 esac
267 if [ ! -f $osx_zip ]; then
268 echo "$osx_zip files not found. Place those in base directory and try again."
269 exit 1
272 if [ $build_files = "yes" ]; then
273 build
274 echo
277 if [ ! -f $src_gz -o ! -f $src_bz2 ]; then
278 echo "$src_gz or $src_bz2 not found. Rebuild and try again"
279 exit 1
282 if [ ! -f $win_zip -o ! -f $win_exe ]; then
283 echo "$win_zip or $win_exe not found. Rebuild and try again"
284 exit 1
287 # Check for uncommitted/queued changes.
288 if [ "$ignore_changes" != "yes" ]; then
289 set +e
290 git diff --exit-code > /dev/null 2>&1
291 if [ $? -ne 0 ]; then
292 echo "Uncommitted changes found. Did you forget to commit? Aborting."
293 echo "Use --ignore-local-changes to skip this check."
294 exit 1
296 set -e
299 create_email > $email_file
301 username="${user},sox"
303 if [ $update_web = "yes" -o $release_files = "yes" ]; then
304 echo "Creating shell on sourceforge for $username"
305 ssh ${username}@${hostname} create
308 if [ $update_web = "yes" ]; then
309 echo "Updating web pages..."
310 # Delete only PNG filenames which have random PID #'s in them.
311 ssh ${username}@${hostname} rm -rf ${web_path}/soxpng
312 scp -pr *.pdf *.html soxpng ${username}@${hostname}:${web_path}
313 scp -p Docs.Features ${username}@${hostname}:${web_path/wiki.d}
316 if [ $release_files = "yes" ]; then
317 ssh ${username}@${hostname} mkdir -p ${release_path}/${rcpath}${module}/${release_num}
318 rsync -avz --delete --progress $release_list ${username}@${hostname}:${release_path}/${rcpath}${module}/${release_num}
319 # FIXME: Stop pushing this and need to find a solution to help push it later.
320 #scp -p NEWS ${username}@${hostname}:${release_path}/${rcpath}${module}/${release_num}/README