#!/bin/sh if ! [ -d .git ]; then echo "Not a git archive" exit 1 fi if [ -n "$1" ]; then echo Creating a tarball with version $1 fi _owd=`pwd` _cwd=`basename $_owd` _branch=`git branch | grep "^\*" | awk '{print $2}'` _archive=$_cwd-$_branch-`date +%Y-%m-%d`.tar.gz TMPDIR=$(mktemp -d /tmp/$_cwd-XXXXXX) cd .. cp -a $_cwd $TMPDIR cd $TMPDIR if [ -n "$1" ]; then mv $_cwd $_cwd-$1 _cwd="$_cwd-$1" _archive=$_cwd.tar.gz fi tar --exclude .git -czvf $_archive $_cwd cd $_owd cp $TMPDIR/$_archive . rm -rf $TMPDIR