
ITCH_CHANNEL=snamellit/Bloatrunner

if [[ ! -f Makefile ]]; then 
  make distclean
fi

./bootstrap.sh
./configure GUILE=$(which guile)
make -j16
make dist 

SOURCETAR="@PACKAGE@-@VERSION@.tar.gz"

if [ -f "$SOURCETAR" ]; then
  echo "Found source tarball $SOURCE"
  BASENAME="@PACKAGE@-@VERSION@"

  echo releasing $BASENAME

  butler push $SOURCETAR $ITCH_CHANNEL:source

  TARBALL=$(guix pack -R -Sbloatrunner=bin -L .guix/modules bloatrunner)
  echo created $TARBALL
  TARGETNAME=/tmp/$BASENAME-linux-x86_64.tar.gz 
  echo copy $TARBALL to $TARGETNAME
  rm -f $TARGETNAME
  cp $TARBALL $TARGETNAME

  echo push $TARGETNAME
  butler push $TARGETNAME $ITCH_CHANNEL:linux-x86_64

else
  echo "No source tarball found"
  exit 1
fi
