Merge remote branch 'remotes/gullydwarf-cfdv/f424_email_verified_messaging'
[mediagoblin.git] / maketarball.sh
1 #!/bin/bash
2
3 # usage: maketarball
4 # maketarball <tag>
5 #
6 # With no arguments, this creates a source tarball from git master with a
7 # filename based on today's date.
8 #
9 # With a <tag> argument, this creates a tarball of the tag.
10 #
11 # Examples:
12 #
13 # ./maketarball
14 # ./maketarball v0.0.2
15
16 NOWDATE=`date "+%Y-%m-%d"`
17
18 if [ -z "$1" ]
19 then
20 REVISH=master
21 PREFIX="$NOWDATE-$REVISH"
22 else
23 REVISH=$1
24 PREFIX="$REVISH"
25 fi
26
27 # convert PREFIX to all lowercase.
28 # nix the v from tag names.
29 PREFIX=`echo "$PREFIX" | tr '[A-Z]' '[a-z]' | sed s/v//`
30
31 echo "== REVISH $REVISH"
32 echo "== PREFIX $PREFIX"
33
34 echo ""
35
36 echo "generating archive...."
37 git archive \
38 --format=tar \
39 --prefix=mediagoblin-$PREFIX/ \
40 $REVISH > mediagoblin-$PREFIX.tar
41
42 if [[ $? -ne 0 ]]
43 then
44 echo "git archive command failed. See above text for reason."
45 if [[ -e mediagoblin-$PREFIX.tar ]]
46 then
47 rm mediagoblin-$PREFIX.tar
48 fi
49 exit 1;
50 fi
51
52 echo "compressing...."
53 gzip mediagoblin-$PREFIX.tar
54
55 echo "archive at mediagoblin-$PREFIX.tar.gz"
56
57 echo "done."