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
|
|
|
|
set -x
|
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-04-11 16:38:32 +02:00
|
|
|
OSX=true
|
|
|
|
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then
|
|
|
|
LINUX=true
|
|
|
|
else
|
|
|
|
echo "Platform detection failed"
|
|
|
|
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-03-09 19:21:46 +01:00
|
|
|
ICON="$BUILD_DIR/icons/lbry48.png"
|
2017-01-25 07:24:04 +01:00
|
|
|
fi
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if [ "$FULL_BUILD" == "true" ]; then
|
2017-01-18 20:43:35 +01:00
|
|
|
# install dependencies
|
2017-03-09 19:21:46 +01:00
|
|
|
$BUILD_DIR/prebuild.sh
|
2017-01-18 20:43:35 +01:00
|
|
|
|
2017-03-09 19:21:46 +01:00
|
|
|
VENV="$BUILD_DIR/venv"
|
2017-01-19 10:51:54 +01:00
|
|
|
if [ -d "$VENV" ]; then
|
|
|
|
rm -rf "$VENV"
|
|
|
|
fi
|
|
|
|
virtualenv "$VENV"
|
|
|
|
set +u
|
|
|
|
source "$VENV/bin/activate"
|
|
|
|
set -u
|
2017-03-09 19:21:46 +01:00
|
|
|
pip install -r "$BUILD_DIR/requirements.txt"
|
|
|
|
python "$BUILD_DIR/set_version.py"
|
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"
|
|
|
|
mkdir -p "$ROOT/dist"
|
|
|
|
[ -d "$ROOT/app/dist" ] && rm -rf "$ROOT/app/dist"
|
2017-03-07 00:00:57 +01:00
|
|
|
mkdir -p "$ROOT/app/dist"
|
2017-03-06 23:17:03 +01:00
|
|
|
|
2017-01-27 02:38:52 +01:00
|
|
|
npm install
|
2017-03-06 23:17:03 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
############
|
|
|
|
# UI #
|
|
|
|
############
|
2017-01-18 17:37:44 +01:00
|
|
|
|
|
|
|
(
|
2017-03-09 18:31:07 +01:00
|
|
|
cd "$ROOT/ui"
|
2017-01-18 17:37:44 +01:00
|
|
|
npm install
|
|
|
|
node_modules/.bin/node-sass --output dist/css --sourcemap=none scss/
|
|
|
|
node_modules/.bin/webpack
|
2017-03-07 16:28:37 +01:00
|
|
|
cp -r dist/* "$ROOT/app/dist/"
|
2017-01-18 17:37:44 +01:00
|
|
|
)
|
|
|
|
|
2017-01-16 20:06:53 +01:00
|
|
|
|
2017-01-26 19:30:02 +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-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-04-19 21:16:29 +02:00
|
|
|
DAEMON_URL="$(cat "$BUILD_DIR/DAEMON_URL" | sed "s/OSNAME/${OSNAME}/")"
|
2017-04-26 19:08:11 +02:00
|
|
|
wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip"
|
2017-04-19 21:16:29 +02:00
|
|
|
unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/"
|
2017-04-26 19:08:11 +02:00
|
|
|
rm "$BUILD_DIR/daemon.zip"
|
2017-03-07 16:28:37 +01:00
|
|
|
|
2017-03-06 23:17:03 +01:00
|
|
|
###################
|
|
|
|
# Build the app #
|
|
|
|
###################
|
|
|
|
|
|
|
|
(
|
|
|
|
cd "$ROOT/app"
|
|
|
|
npm install
|
|
|
|
)
|
|
|
|
|
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-02-10 01:54:42 +01:00
|
|
|
node_modules/.bin/build -p never
|
2017-03-07 16:28:37 +01:00
|
|
|
|
2017-04-11 16:38:32 +02:00
|
|
|
if $OSX; then
|
|
|
|
binary_name=$(find "$ROOT/dist" -iname "*dmg")
|
|
|
|
new_name=$(basename "$binary_name" | sed 's/-/_/')
|
|
|
|
mv "$binary_name" "$(dirname "$binary_name")/$new_name"
|
|
|
|
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-03-09 21:41:17 +01:00
|
|
|
python "$BUILD_DIR/release_on_tag.py"
|
2017-02-10 01:53:07 +01:00
|
|
|
|
2017-03-06 23:17:03 +01:00
|
|
|
deactivate
|
|
|
|
|
2017-01-18 18:05:46 +01:00
|
|
|
echo 'Build and packaging complete.'
|
|
|
|
else
|
2017-02-08 17:20:34 +01:00
|
|
|
echo 'Build complete. Run `./node_modules/.bin/electron app` to launch the app'
|
2017-04-19 21:16:29 +02:00
|
|
|
fi
|