2019-08-27 06:08:26 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
NODE_REQUIRED_VERSION=v12.13.1
|
|
|
|
|
|
|
|
# Check basic dependencies
|
2019-08-27 06:08:26 -05:00
|
|
|
if ! [ -x "$(command -v git)" ]; then
|
|
|
|
echo 'GIT does not exist! Please set it up before running this script!' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# Switch to the appropriate node version for the branch using NVM
|
|
|
|
if [ -x "$(command -v nvm)" ]; then
|
|
|
|
echo 'NVM does not not exist! Install it to switch to the appropriate node version!' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Source all the profile files to ensure nvm is in path
|
|
|
|
source $HOME/.nvm/nvm.sh
|
|
|
|
|
|
|
|
NODE_CURRENT_VERSION=$(nvm current)
|
|
|
|
if [ "$NODE_REQUIRED_VERSION" != "$NODE_CURRENT_VERSION" ]; then
|
|
|
|
echo 'Node version does not match required version! Installing the required version' >&2
|
|
|
|
nvm install $NODE_REQUIRED_VERSION
|
|
|
|
nvm use $NODE_REQUIRED_VERSION
|
|
|
|
fi
|
|
|
|
|
2019-08-27 06:08:26 -05:00
|
|
|
if ! [ -x "$(command -v node)" ]; then
|
|
|
|
echo 'NODE does not exist! Please set it up before running this script!' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-08-28 09:05:10 -05:00
|
|
|
if ! [ -x "$(command -v npm)" ]; then
|
|
|
|
echo 'NPM does not exist! Please set it up before running this script!' >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
if ! [ -x "$(command -v gulp)" ]; then
|
|
|
|
echo 'Gulp does not exist! Install it for setting expiry!' >&2
|
2019-08-27 06:08:26 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
if ! [ -x "$(command -v /usr/local/bin/packagesbuild)" ]; then
|
|
|
|
echo 'Packages build does not exist! Please set it up before running this script!' >&2
|
2019-08-28 04:58:49 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# If we don't get parent build number from parent job, set it to 0
|
2019-08-28 04:58:49 -05:00
|
|
|
if [ -z "$PARENT_BUILD_VERSION" ]; then
|
|
|
|
echo "PARENT_BUILD_VERSION is empty, setting default"
|
|
|
|
PARENT_BUILD_VERSION="0"
|
|
|
|
fi
|
|
|
|
|
2019-08-27 06:08:26 -05:00
|
|
|
NODE_VERSION=$(node --version)
|
2019-12-12 06:03:37 -06:00
|
|
|
echo "Executing using Node Version: ${NODE_VERSION}"
|
2019-08-27 06:08:26 -05:00
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# We need to include swift search libraries to build SDA
|
2019-08-27 06:08:26 -05:00
|
|
|
if [ ! -d "$HOME/tronlibraries/library" ]; then
|
|
|
|
echo 'Search libraries do not exist! Not building with swift search' >&2
|
|
|
|
else
|
|
|
|
cp -r "$HOME/tronlibraries/library" .
|
|
|
|
fi
|
|
|
|
|
|
|
|
PKG_VERSION=$(node -e "console.log(require('./package.json').version);")
|
|
|
|
|
|
|
|
# Install app dependencies
|
|
|
|
npm install
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# Replace url in config
|
2019-08-27 06:08:26 -05:00
|
|
|
echo "Setting default pod url to https://corporate.symphony.com"
|
|
|
|
sed -i -e 's/\"url\"[[:space:]]*\:[[:space:]]*\".*\"/\"url\":\"https:\/\/corporate.symphony.com\"/g' config/Symphony.config
|
2019-12-12 06:03:37 -06:00
|
|
|
|
|
|
|
# Setup the build version
|
2019-08-27 06:08:26 -05:00
|
|
|
echo "Setting build version to ${PARENT_BUILD_VERSION}"
|
2019-08-28 04:58:49 -05:00
|
|
|
sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\" ${PARENT_BUILD_VERSION}\"/g" package.json
|
2019-12-12 06:03:37 -06:00
|
|
|
|
|
|
|
# Replace version number in pre-install script
|
2019-08-27 06:08:26 -05:00
|
|
|
echo "Setting package version in pre install script to ${PKG_VERSION}"
|
|
|
|
sed -i -e "s/CURRENT_VERSION=APP_VERSION/CURRENT_VERSION=${PKG_VERSION}/g" ./installer/mac/preinstall.sh
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# Set expiry period for TTL builds
|
2019-08-28 04:58:49 -05:00
|
|
|
if [ -z "$EXPIRY_PERIOD" ]; then
|
|
|
|
echo 'Expiry period not set, so, not creating expiry for the build'
|
|
|
|
else
|
|
|
|
gulp setExpiry --period ${EXPIRY_PERIOD}
|
|
|
|
fi
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# Build the app
|
2019-08-27 06:08:26 -05:00
|
|
|
echo "Running tests, code coverage, linting and building..."
|
|
|
|
npm run unpacked-mac
|
|
|
|
|
|
|
|
# Create .pkg installer
|
|
|
|
echo "Creating .pkg"
|
|
|
|
/usr/local/bin/packagesbuild -v installer/mac/symphony-mac-packager.pkgproj
|