rel=$1
tag=`date +%s`
BB_ACCESS=`cat ~/.bitbucket`
echo $rel $tag

hg clone https://bitbucket.org/Spivey/obc-3 -u $rel obc-$tag
cd obc-$tag
autoreconf \
&& sh macport/macconfig \
&& make \
&& make test0 \
&& make test \
&& (cd macport; make package \
  && curl -u $BB_ACCESS \
        https://api.bitbucket.org/2.0/repositories/Spivey/obc-3/downloads \
	-F files=@`echo obc-mac-*.pkg`) \
&& echo Done.
