2019-08-27 06:08:26 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-12-15 06:44:22 -06:00
|
|
|
# Unlock the keychain
|
|
|
|
echo "Unlocking keychain"
|
|
|
|
security -v unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_NAME"
|
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
NODE_REQUIRED_VERSION=v12.13.1
|
2020-04-01 09:17:52 -05:00
|
|
|
SNYK_ORG=sda
|
2020-11-10 03:41:39 -06:00
|
|
|
SNYK_PROJECT_NAME="Symphony Desktop Application"
|
2019-12-12 06:03:37 -06:00
|
|
|
|
|
|
|
# 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
|
2019-12-30 09:36:47 -06:00
|
|
|
echo 'Gulp does not exist! Installing it!' >&2
|
2020-05-01 00:03:56 -05:00
|
|
|
npm install -g gulp gulp-cli
|
2019-12-30 09:36:47 -06:00
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -x "$(command -v snyk)" ]; then
|
|
|
|
echo 'Snyk does not exist! Installing and setting it up' >&2
|
|
|
|
npm install -g snyk
|
2019-08-27 06:08:26 -05:00
|
|
|
fi
|
2020-04-01 09:35:15 -05:00
|
|
|
echo "Setting snyk org to $SNYK_ORG and api token to $SNYK_API_TOKEN"
|
|
|
|
snyk config set org="$SNYK_ORG"
|
|
|
|
snyk config set api="$SNYK_API_TOKEN"
|
2019-08-27 06:08:26 -05:00
|
|
|
|
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" .
|
2020-02-13 12:11:16 -06:00
|
|
|
echo 'Copied search libraries'
|
|
|
|
ls -lrth $HOME/tronlibraries/library
|
2019-08-27 06:08:26 -05:00
|
|
|
fi
|
|
|
|
|
2020-02-13 12:11:16 -06:00
|
|
|
codesign --force --options runtime -s "Developer ID Application: Symphony Communication Services LLC" library/lz4.exec
|
|
|
|
codesign --force --options runtime -s "Developer ID Application: Symphony Communication Services LLC" library/indexvalidator.exec
|
|
|
|
|
2019-08-27 06:08:26 -05:00
|
|
|
PKG_VERSION=$(node -e "console.log(require('./package.json').version);")
|
|
|
|
|
|
|
|
# Install app dependencies
|
2019-12-30 09:36:47 -06:00
|
|
|
echo "Installing dependencies"
|
2019-08-27 06:08:26 -05:00
|
|
|
npm install
|
|
|
|
|
2020-06-01 07:38:01 -05:00
|
|
|
echo "Signing screen share indicator"
|
|
|
|
codesign --force --options runtime -s "Developer ID Application: Symphony Communication Services LLC" node_modules/screen-share-indicator-frame/SymphonyScreenShareIndicator
|
|
|
|
|
2019-12-30 09:36:47 -06:00
|
|
|
# Run Snyk Security Tests
|
|
|
|
echo "Running snyk security tests"
|
2020-11-10 03:41:39 -06:00
|
|
|
snyk test --file=package-lock.json --org="$SNYK_ORG"
|
|
|
|
snyk monitor --file=package-lock.json --org="$SNYK_ORG" --project-name="$SNYK_PROJECT_NAME"
|
2019-12-30 09:36:47 -06:00
|
|
|
|
2019-12-12 06:03:37 -06:00
|
|
|
# Replace url in config
|
2020-04-27 06:04:56 -05:00
|
|
|
echo "Setting default pod url to https://my.symphony.com"
|
|
|
|
sed -i -e 's/\"url\"[[:space:]]*\:[[:space:]]*\".*\"/\"url\":\"https:\/\/my.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
|
2020-05-01 00:03:56 -05:00
|
|
|
if [ "$EXPIRY_PERIOD" == "0" ] || [ "$EXPIRY_PERIOD" == 0 ]; then
|
2019-08-28 04:58:49 -05:00
|
|
|
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
|
2020-12-14 07:45:37 -06:00
|
|
|
|
2020-12-15 06:44:22 -06:00
|
|
|
PACKAGE=installer/mac/build/Symphony.pkg
|
|
|
|
if [ ! -e ${PACKAGE} ]; then
|
|
|
|
echo "BUILD PACKAGE FAILED: package not created: ${PACKAGE}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Package created: ${PACKAGE}"
|
|
|
|
|
|
|
|
# Sign the app
|
|
|
|
PKG_VERSION=$(node -e "console.log(require('./package.json').version);")
|
|
|
|
echo "Signing Package: ${PACKAGE}"
|
|
|
|
SIGNED_PACKAGE=installer/mac/build/Symphony_Signed_${PKG_VERSION}_${PARENT_BUILD_VERSION}.pkg
|
|
|
|
productsign --sign "Developer ID Installer: Symphony Communication Services LLC" $PACKAGE $SIGNED_PACKAGE
|
|
|
|
echo "Signing Package complete: ${PACKAGE}"
|
|
|
|
|
|
|
|
# Notarize the app
|
|
|
|
xcrun altool --notarize-app --primary-bundle-id "$BUNDLE_ID" --username "$APPLE_ID" --password "$APPLE_ID_PASSWORD" --file $SIGNED_PACKAGE > /tmp/notarize.txt
|
|
|
|
cat /tmp/notarize.txt
|
|
|
|
REQUEST_ID=$(sed -n '2p' /tmp/notarize.txt)
|
|
|
|
REQUEST_ID=$(echo $REQUEST_ID | cut -d "=" -f 2)
|
|
|
|
echo "$REQUEST_ID"
|
|
|
|
#xcrun altool --notarization-info $REQUEST_ID --username "$APPLE_ID" --password "$APPLE_ID_PASSWORD"
|
|
|
|
#xcrun stapler staple $SIGNED_PACKAGE
|
|
|
|
#stapler validate --verbose $SIGNED_PACKAGE
|
|
|
|
|
|
|
|
# Generate Installation Instructions PDF
|
2020-12-14 07:45:37 -06:00
|
|
|
if ! [ -x "$(command -v markdown-pdf)" ]; then
|
|
|
|
echo 'Markdown PDF does not exist! Installing it' >&2
|
|
|
|
npm install -g markdown-pdf
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Generating PDF for installation instructions"
|
|
|
|
markdown-pdf installer/mac/install_instructions_mac.md
|
|
|
|
|
|
|
|
# Create targets directory
|
|
|
|
mkdir -p targets
|
|
|
|
|
2020-12-15 06:44:22 -06:00
|
|
|
# Attach artifacts to build
|
2020-12-14 07:45:37 -06:00
|
|
|
if [ "${EXPIRY_PERIOD}" != "0" ]; then
|
2020-12-15 06:44:22 -06:00
|
|
|
cp $SIGNED_PACKAGE "targets/Symphony-macOS-${PKG_VERSION}-${PARENT_BUILD_VERSION}-TTL-${EXPIRY_PERIOD}.pkg"
|
2020-12-14 07:45:37 -06:00
|
|
|
cp installer/mac/install_instructions_mac.pdf "targets/Install-Instructions-macOS-${PKG_VERSION}-${PARENT_BUILD_VERSION}-TTL-${EXPIRY_PERIOD}.pdf"
|
|
|
|
else
|
2020-12-15 06:44:22 -06:00
|
|
|
cp $SIGNED_PACKAGE "targets/Symphony-macOS-${PKG_VERSION}-${PARENT_BUILD_VERSION}.pkg"
|
2020-12-14 07:45:37 -06:00
|
|
|
cp installer/mac/install_instructions_mac.pdf "targets/Install-Instructions-macOS-${PKG_VERSION}-${PARENT_BUILD_VERSION}.pdf"
|
|
|
|
fi
|
2020-12-15 06:44:22 -06:00
|
|
|
|
|
|
|
echo "All done, job successfull :)"
|