#!/bin/bash
((!$#)) && echo Missing release message! && exit 1
export RELEASE="v$(date -u +"%y.%m%d.%H%M")"
pushd ~/github.com/josd/eye
cat eye.pl | sed -e "s/EYE.*josd/EYE $RELEASE josd/" > eye.pl.tmp
mv eye.pl.tmp 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
./test
git diff
mkdir -p /tmp/eye
cp -a eye.pl eye.sh eye.sh.in eye.cmd install.sh install.cmd INSTALL LICENSE RELEASE README VERSION /tmp/eye
pushd /tmp
zip -9ur eye.zip eye
popd
cp -a /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
