Blob Blame Raw
#!/bin/bash

# you may set env var EXAMPLESROOT (helianthus-examples repo)

set -e

ROOT="$(cd `dirname "$0"`; pwd)"
cd "$ROOT"

if [ -z "$EXAMPLESROOT" ]; then
	EXAMPLESROOT="$ROOT/../helianthus-examples"
fi

VER="$(git describe --tags)"
PUBDIR="$ROOT/build-publish"
mkdir -p "$PUBDIR"


# build win
if [ "$1" != "fast" ]; then
	echo " -- build win -- "
	cd "$ROOT/win"
	./rebuild-heli-win.sh
	cd "$ROOT"
fi


# prepare sources
echo " -- prepare sources -- "
SRCNAME="helianthus-src-$VER"
SRCDIR="$PUBDIR/$SRCNAME"
rm -rf "$SRCDIR"
mkdir -p "$SRCDIR"
cd "$SRCDIR"
git --work-tree=. checkout .
cd "$ROOT"


# prepare binaries
echo " -- prepare binaries -- "
BINNAME="helianthus-bin-$VER"
BINDIR="$PUBDIR/$BINNAME"
rm -rf "$BINDIR"
cp -r "$ROOT/win/release" "$BINDIR"
cp -r "$ROOT/win/unpack" "$BINDIR/src"
rm -f "$BINDIR/src/"*.done
cp -r "$SRCDIR" "$BINDIR/src/"
echo "Binary files licensed under GPL. Look license notes in src directory and subdirectories" >> "$BINDIR/readme"


# prepare examples
echo " -- prepare examples -- "
HELIROOT="$ROOT" "$EXAMPLESROOT/publish.sh"
cp -r "$EXAMPLESROOT/build-publish/"* "$BINDIR/"
cp -r "$EXAMPLESROOT/build-publish/"* "$SRCDIR/"
rm -rf "$SRCDIR/examples"*/bin


# prepare archives
cd "$PUBDIR"
echo " -- prepare archives -- "
rm -f "$BINNAME.tar.gz"
rm -f "$SRCNAME.tar.gz"
rm -f "$BINNAME.zip"
rm -f "$SRCNAME.zip"
echo     "$BINNAME.tar.gz"
tar -czf "$BINNAME.tar.gz" "$BINNAME"
echo     "$SRCNAME.tar.gz"
tar -czf "$SRCNAME.tar.gz" "$SRCNAME"
echo     "$BINNAME.zip"
zip -rq  "$BINNAME.zip" "$BINNAME"
echo     "$SRCNAME.zip"
zip -rq  "$SRCNAME.zip" "$SRCNAME"
cd "$ROOT"

echo " -- done -- "