aboutsummaryrefslogtreecommitdiffstats
path: root/maketarball.sh
blob: 2ee780168c4194a871c555c0457494ddb7579702 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

# usage: maketarball
#        maketarball <tag>
#
# With no arguments, this creates a source tarball from git master with a
# filename based on today's date.
#
# With a <tag> argument, this creates a tarball of the tag.
#
# Examples:
#
#    ./maketarball
#    ./maketarball v0.0.2

NOWDATE=`date "+%Y-%m-%d"`

if [ -z "$1" ]
then
    REVISH=master
    PREFIX="$NOWDATE-$REVISH"
else
    REVISH=$1
    PREFIX="$REVISH"
fi

# convert PREFIX to all lowercase.
# nix the v from tag names.
PREFIX=`echo "$PREFIX" | tr '[A-Z]' '[a-z]' | sed s/v//`

echo "== REVISH $REVISH"
echo "== PREFIX $PREFIX"

echo ""

echo "generating archive...."
git archive \
    --format=tar \
    --prefix=mediagoblin-$PREFIX/ \
    $REVISH > mediagoblin-$PREFIX.tar

if [[ $? -ne 0 ]]
then
    echo "git archive command failed.  See above text for reason."
    if [[ -e mediagoblin-$PREFIX.tar ]]
    then
        rm mediagoblin-$PREFIX.tar
    fi
    exit 1;
fi

echo "compressing...."
gzip mediagoblin-$PREFIX.tar

echo "archive at mediagoblin-$PREFIX.tar.gz"

echo "done."