#!/bin/bash

version=$1
name=genome-enhancer-$version
workdir=/tmp
cvsname=ge

if [ -z "$version" ]; then
    echo "Usage: $0 <version>"
    echo "Tags the CVS repository and creates a release tarfile in $workdir."
    exit 1
fi

# Tag the repository.
tag=`echo "RELEASE_$version" | sed -e 's/\./_/'`
echo cvs tag $tag

# Check out the current version of the project.
rm -rf $workdir/$name
cd $workdir
cvs co -d $name $cvsname

# Remove unnecessary files from the release.
rm -r `find . -name CVS` `find . -name .cvsignore`

# Remove the password from the application configuration.
cd $workdir/$name
cat site/ge/app.py | sed -e "s/^_dbhost *=.*$/_dbhost = 'localhost'/" \
                         -e "s/^_dbuser *=.*$/_dbuser = 'username'/" \
                         -e "s/^_dbpass *=.*$/_dbpass = 'password'/" \
    > site/ge/app.py.generic
mv site/ge/app.py.generic site/ge/app.py

# Create the release tarfile.
cd $workdir
tar cvfz $name.tar.gz $name

echo
echo Release archive at $workdir/$name.tar.gz has been created.
