2017-01-18 22:39:21 +01:00
#!/bin/bash
2017-01-16 20:06:53 +01:00
2017-03-06 23:17:03 +01:00
set -euo pipefail
2017-01-16 20:06:53 +01:00
2017-03-09 19:21:46 +01:00
ROOT = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) /.. " && pwd ) "
2017-03-03 04:43:34 +01:00
cd " $ROOT "
2017-03-09 19:21:46 +01:00
BUILD_DIR = " $ROOT /build "
2017-03-03 04:43:34 +01:00
2017-04-11 16:38:32 +02:00
LINUX = false
OSX = false
2017-01-25 07:24:04 +01:00
if [ " $( uname) " = = "Darwin" ] ; then
2017-09-21 15:29:51 +02:00
echo -e "\033[0;32mBuilding for OSX\x1b[m"
2017-04-11 16:38:32 +02:00
OSX = true
elif [ " $( expr substr $( uname -s) 1 5) " = = "Linux" ] ; then
2017-09-21 15:29:51 +02:00
echo -e "\033[0;32mBuilding for Linux\x1b[m"
2017-04-11 16:38:32 +02:00
LINUX = true
else
2017-09-09 08:46:26 +02:00
echo -e "\033[1;31mPlatform detection failed\x1b[m"
2017-04-11 16:38:32 +02:00
exit 1
fi
if $OSX ; then
2017-03-09 19:21:46 +01:00
ICON = " $BUILD_DIR /icon.icns "
2017-01-25 07:24:04 +01:00
else
2017-09-07 01:16:21 +02:00
ICON = " $BUILD_DIR /icons/48x48.png "
2017-01-25 07:24:04 +01:00
fi
2017-09-21 15:29:51 +02:00
2017-02-10 20:11:26 +01:00
FULL_BUILD = " ${ FULL_BUILD :- false } "
2017-03-03 04:43:34 +01:00
if [ -n " ${ TEAMCITY_VERSION :- } " -o -n " ${ APPVEYOR :- } " ] ; then
2017-02-10 20:11:26 +01:00
FULL_BUILD = "true"
fi
2017-11-10 16:47:51 +01:00
DEPS = " ${ DEPS :- $FULL_BUILD } "
if [ " $DEPS " != "true" ] ; then
2017-10-27 05:30:48 +02:00
echo -e "\033[1;36mDependencies will NOT be installed. Run with \"INSTALL_DEPENDENCIES=true\" to install dependencies, or \"FULL_BUILD=true\" to install dependencies and build a complete app.\x1b[m"
else
2017-01-18 20:43:35 +01:00
# install dependencies
2017-09-13 07:19:50 +02:00
echo -e "\033[0;32mInstalling Dependencies\x1b[m"
2017-11-10 16:47:51 +01:00
" $BUILD_DIR /install_deps.sh "
2017-01-18 22:35:06 +01:00
fi
2017-01-18 22:33:27 +01:00
2017-03-07 16:28:37 +01:00
[ -d " $ROOT /dist " ] && rm -rf " $ROOT /dist "
2017-03-06 23:17:03 +01:00
2017-06-23 21:18:03 +02:00
yarn install
2017-03-06 23:17:03 +01:00
2017-03-07 16:28:37 +01:00
####################
2017-03-16 02:23:04 +01:00
# daemon and cli #
2017-03-07 16:28:37 +01:00
####################
2017-09-13 07:19:50 +02:00
echo -e "\033[0;32mGrabbing Daemon and CLI\x1b[m"
2017-04-19 21:16:29 +02:00
if $OSX ; then
OSNAME = "macos"
else
OSNAME = "linux"
2017-04-11 16:38:32 +02:00
fi
2017-11-29 01:29:59 +01:00
DAEMON_VER = $( node -e " console.log(require(\" $ROOT /package.json\").lbrySettings.lbrynetDaemonVersion) " )
DAEMON_URL_TEMPLATE = $( node -e " console.log(require(\" $ROOT /package.json\").lbrySettings.lbrynetDaemonUrlTemplate) " )
2017-08-11 04:02:14 +02:00
DAEMON_URL = $( echo ${ DAEMON_URL_TEMPLATE //DAEMONVER/ $DAEMON_VER } | sed " s/OSNAME/ $OSNAME /g " )
2017-08-16 04:15:03 +02:00
DAEMON_VER_PATH = " $BUILD_DIR /daemon.ver "
echo " $DAEMON_VER_PATH "
2017-12-04 21:46:51 +01:00
if [ [ ! -f $DAEMON_VER_PATH || ! -f $ROOT /static/daemon/lbrynet-daemon || " $( < " $DAEMON_VER_PATH " ) " != " $DAEMON_VER " ] ] ; then
2017-10-27 05:30:48 +02:00
curl -sL -o " $BUILD_DIR /daemon.zip " " $DAEMON_URL "
2017-12-04 21:46:51 +01:00
unzip " $BUILD_DIR /daemon.zip " -d " $ROOT /static/daemon/ "
2017-08-16 04:15:03 +02:00
rm " $BUILD_DIR /daemon.zip "
echo " $DAEMON_VER " > " $DAEMON_VER_PATH "
else
2017-09-09 08:46:26 +02:00
echo -e " \033[4;31mAlready have daemon version $DAEMON_VER , skipping download\x1b[m "
2017-08-16 04:15:03 +02:00
fi
2017-03-07 16:28:37 +01:00
2017-07-19 23:05:08 +02:00
2017-03-06 23:17:03 +01:00
###################
# Build the app #
###################
2017-02-10 20:11:26 +01:00
if [ " $FULL_BUILD " = = "true" ] ; then
2017-04-11 16:38:32 +02:00
if $OSX ; then
2017-01-27 03:36:05 +01:00
security unlock-keychain -p ${ KEYCHAIN_PASSWORD } osx-build.keychain
fi
2017-01-18 19:03:10 +01:00
2017-12-20 15:48:38 +01:00
yarn build
2017-03-07 16:28:37 +01:00
2017-12-08 02:38:10 +01:00
# Workaround: TeamCity expects the dmg to be in dist/mac, but in the new electron-builder
# it's put directly in dist/ (the right way to solve this is to update the TeamCity config)
if $OSX ; then
cp dist/*.dmg dist/mac
fi
2017-03-07 16:28:37 +01:00
# electron-build has a publish feature, but I had a hard time getting
# it to reliably work and it also seemed difficult to configure. Not proud of
# this, but it seemed better to write my own.
2017-11-10 16:47:51 +01:00
VENV = " $BUILD_DIR /venv "
if [ -d " $VENV " ] ; then
rm -rf " $VENV "
fi
virtualenv " $VENV "
" $VENV /bin/pip " install -r " $BUILD_DIR /requirements.txt "
" $VENV /bin/python " " $BUILD_DIR /upload_assets.py "
2017-03-06 23:17:03 +01:00
2017-09-09 08:46:26 +02:00
echo -e '\033[0;32mBuild and packaging complete.\x1b[m'
2017-01-18 18:05:46 +01:00
else
2017-12-07 16:40:49 +01:00
echo -e 'Build complete. Run \033[1;31myarn dev\x1b[m to launch the app'
2017-04-19 21:16:29 +02:00
fi