Makes maketarball more resilient to errors
[mediagoblin.git] / maketarball.sh
CommitLineData
7c6dffe3
WKG
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
16NOWDATE=`date "+%Y-%m-%d"`
17
18if [ -z "$1" ]
19then
20 REVISH=master
21 PREFIX="$NOWDATE-$REVISH"
22else
23 REVISH=$1
24 PREFIX="$REVISH"
25fi
26
27# convert PREFIX to all lowercase.
28# nix the v from tag names.
29PREFIX=`echo "$PREFIX" | tr '[A-Z]' '[a-z]' | sed s/v//`
30
31echo "== REVISH $REVISH"
32echo "== PREFIX $PREFIX"
33
34echo ""
35
36echo "generating archive...."
37git archive \
38 --format=tar \
39 --prefix=mediagoblin-$PREFIX/ \
40 $REVISH > mediagoblin-$PREFIX.tar
41
5ed4722d
WKG
42if [[ $? -ne 0 ]]
43then
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;
50fi
51
7c6dffe3
WKG
52echo "compressing...."
53gzip mediagoblin-$PREFIX.tar
54
55echo "archive at mediagoblin-$PREFIX.tar.gz"
56
57echo "done."