#!/bin/bash
#
# Create Windows releases on my development machine. Mostly dedicated to
# the setup on this machine. Might be useful as a starting point for
# anyone doing something similar. It automates the download, building
# and upload. In addition, it validates that the there are no obvious
# major mistakes during the process.
# Where to upload the final binary
downloaddir="/home/pl/web/download/stable/bin ec:/home/swipl/web/download/stable/bin"
check-src()
{ version=$(git describe | sed 's/V[0-9]\.[0-9][0-9]*\.[0-9][0-9]*//')
if [ ! -z "$version" ]; then
echo "Version is dirty"
exit 1
fi
}
check-doc()
{ [ -f doc-version -a `cat VERSION` = `cat doc-version` ] || exit 1
}
update-src()
{ git pull --tags vu master
./prepare
check-src || exit 1
check-doc || exit 1
version=`cat VERSION`
shortversion=$(echo $version | sed 's/[V.]//g')
}
win-version()
{ case `pwd` in
*mingw32*)
bits=32
;;
*mingw64*)
bits=64
;;
*)
exit 1
esac
}
check-build()
{ if grep -i error: *.out; then
exit 1
fi
}
upload()
{ for d in $downloaddir; do
rsync -P ../../swipl-w${bits}-${shortversion}.exe $d
done
}
build()
{ [ ! -z "$shortversion" ] || update-src || exit 1
win-version || exit 1
. README.mingw win$bits
build_release
check-build || exit 1
upload
}