#!/bin/bash

# Determine project name based on current directory
#PROJECT=$(basename $PWD)

# NOTE: Don't like this?  Then uncomment one of the following as appropriate
#
# Just set it explictly to whatever you like:
PROJECT=meegotouch-theme-meego
#
# Parse it from any Qt *.pro or *.pri files in CWD:
# PROJECT=$(grep -E "TARGET ?= ?" *.pr[io]|cut -d' ' -f3)

# Grab most recent tag from git
TAG=$(git describe --tags --abbrev=0)

# Parse out just the version number
PARTS=(${TAG//-/ })
VERSION=${PARTS[1]}

# Set name of toplevel directory for the archive
PREFIX="${PROJECT}-${VERSION}/"

# Set name of resulting release archive file
ARCHIVE=${PROJECT}-${VERSION}.tar.bz2

[ -e ${ARCHIVE} ] && rm -rf ${ARCHIVE} && echo "Removed: ${ARCHIVE}"

git archive --format=tar --prefix=${PREFIX} $TAG | bzip2 -c -- > ${ARCHIVE} && {
	echo "Created: ${ARCHIVE}"
} || {
	echo "Creation of release archive ${ARCHIVE} failed.  Reason unknown."
}
