blob: 584ea13af184adce092f79e58d506405a072ff3d (
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
|
#!/bin/bash
#
# Archiver
#
# Parameters
BASENAME="`basename $0 | sed -e 's/\(.\)/\U\1/'`"
DIRNAME="`dirname $0`"
BASEDIR="$DIRNAME/.."
#ARCHIVE="$BASEDIR/archive"
ARCHIVE="archive"
REVISION="`git describe --tags 2> /dev/null || git log -1 --format=oneline | cut -d ' ' -f 1`"
# Determine the revision file
if [ -e "public/revision" ]; then
#REVFILE="$BASEDIR/public/revision"
REVFILE="public/revision"
else
REVFILE="public/book/revision"
fi
# Make sure the archive folder exist
mkdir -p $ARCHIVE
# Check for previous build
if [ ! -e "$REVFILE" ]; then
echo "# $BASENAME: skipping: revision file not found"
exit
else
OLD_REVISION="`cat $REVFILE`"
fi
# Check for non-null revision
if [ -z "$OLD_REVISION" ]; then
echo "# $BASENAME: skipping: old revision is null"
exit
fi
# Check if it's a tag
if git tag | grep -q "^${OLD_REVISION}"; then
# Check if archive does not exists
if [ ! -d "$ARCHIVE/$OLD_REVISION" ]; then
echo "# $BASENAME: archiving $OLD_REVISION..."
cp -alf compiled $ARCHIVE/$OLD_REVISION
else
echo "# $BASENAME: revision $OLD_REVISION already archived"
fi
else
echo "# $BASENAME: not archiving: revision $OLD_REVISION is not a tag"
fi
|