#!/bin/bash
((!$#)) && echo Missing release message! && exit 1
export RELEASE="v$(date -u +"%y.%m%d.%H%M")"
pushd ~/github.com/josd/eye
cat /opt/eye/src/eye.pl | sed -e "s/EYE.*josd/EYE $RELEASE josd/" > eye.pl
sed -i '3 i\['"$RELEASE"'] '"$1"'' RELEASE
swipl -q -f eye.pl -g main -- --version 2>&1 | grep josd > VERSION
sudo ./install.sh
pushd reasoning
./test
popd
mkdir -p /tmp/eye
rsync -azv eye.pl eye.sh eye.cmd install.sh install.cmd INSTALL LICENSE RELEASE README VERSION /tmp/eye
pushd /tmp
zip -9ur eye.zip eye
popd
rsync -azv /tmp/eye.zip .
git commit -a -m "$1"
git push
git tag -a $RELEASE -m "$1"
git push origin $RELEASE
popd
rm /tmp/eye.zip
rm -fr /tmp/eye
