#!/bin/bash -e

VERSION_NUMBER=`sed -n -e 's/^VERSION_NUMBER := //p' Makefile`
VERSION_NAME=`sed -n -e 's/^VERSION_NAME := //p' Makefile`
rm -rfv tildefriends-$VERSION_NUMBER
svn export . tildefriends-$VERSION_NUMBER
echo "tildefriends-$VERSION_NUMBER: $VERSION_NAME" > tildefriends-$VERSION_NUMBER/VERSION
tar \
	--exclude=deps/libbacktrace/Isaac.Newton-Opticks.txt \
	--exclude=deps/libsodium/builds \
	--exclude=deps/libsodium/configure \
	--exclude=deps/libsodium/test \
	--exclude=deps/libuv/docs \
	--exclude=deps/libuv/test \
	--exclude=deps/openssl \
	--exclude=deps/speedscope/*.map \
	--exclude=deps/sqlite/shell.c \
	--exclude=deps/zlib/contrib/vstudio \
	--exclude=deps/zlib/doc \
	-caf tildefriends-$VERSION_NUMBER.tar.xz tildefriends-$VERSION_NUMBER
rm -rfv tildefriends-$VERSION_NUMBER
make apk
cp out/TildeFriends-release.apk TildeFriends-$VERSION_NUMBER.apk
