Skip to content

Commit

Permalink
add build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwas Shashidhar committed Aug 29, 2019
1 parent 7666ee5 commit 85928f4
Show file tree
Hide file tree
Showing 4 changed files with 264 additions and 0 deletions.
59 changes: 59 additions & 0 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

if ! [ -x "$(command -v git)" ]; then
echo 'GIT does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v node)" ]; then
echo 'NODE does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v npm)" ]; then
echo 'NPM does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v gulp)" ]; then
echo 'Gulp does not exist! Install it for setting expiry!' >&2
exit 1
fi

if [ -z "$PARENT_BUILD_VERSION" ]; then
echo "PARENT_BUILD_VERSION is empty, setting default"
PARENT_BUILD_VERSION="0"
fi

NODE_VERSION=$(node --version)
echo "Node Version: ${NODE_VERSION}"

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

# replace url in config
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
# setup the build version
echo "Setting build version to ${PARENT_BUILD_VERSION}"
sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\" ${PARENT_BUILD_VERSION}\"/g" package.json
# replace version number in pre-install script
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

if [ -z "$EXPIRY_PERIOD" ]; then
echo 'Expiry period not set, so, not creating expiry for the build'
else
gulp setExpiry --period ${EXPIRY_PERIOD}
fi

echo "Running tests, code coverage, linting and building..."
npm run packed-linux
85 changes: 85 additions & 0 deletions scripts/build-mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/bin/bash

if ! [ -x "$(command -v git)" ]; then
echo 'GIT does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v node)" ]; then
echo 'NODE does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v npm)" ]; then
echo 'NPM does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v /usr/local/bin/packagesbuild)" ]; then
echo 'Packages build does not exist! Please set it up before running this script!' >&2
exit 1
fi

if ! [ -x "$(command -v gulp)" ]; then
echo 'Gulp does not exist! Install it for setting expiry!' >&2
exit 1
fi

if [ -z "$PARENT_BUILD_VERSION" ]; then
echo "PARENT_BUILD_VERSION is empty, setting default"
PARENT_BUILD_VERSION="0"
fi

NODE_VERSION=$(node --version)
echo "Node Version: ${NODE_VERSION}"

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

# replace url in config
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
# setup the build version
echo "Setting build version to ${PARENT_BUILD_VERSION}"
sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\" ${PARENT_BUILD_VERSION}\"/g" package.json
# replace version number in pre-install script
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

if [ -z "$EXPIRY_PERIOD" ]; then
echo 'Expiry period not set, so, not creating expiry for the build'
else
gulp setExpiry --period ${EXPIRY_PERIOD}
fi

echo "Running tests, code coverage, linting and building..."
npm run unpacked-mac

APP_BUILD=dist/mac/Symphony.app

# Test if app was built and exists, if not, exit
if [ ! -e ${APP_BUILD} ]; then
echo "BUILD FAILED: app does not exist: ${APP_BUILD}"
exit 1
fi

echo "App created: ${APP_BUILD}"

# Create .pkg installer
echo "Creating .pkg"
/usr/local/bin/packagesbuild -v installer/mac/symphony-mac-packager.pkgproj
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}"
60 changes: 60 additions & 0 deletions scripts/build-win32.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:: Check to ensure that the VSDev command prompt is in the below location
echo "Starting VSDev Command Prompt"
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"

echo %PATH%

set DISABLE_REBUILD=true

set PATH=%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd
echo %PATH%

set PATH=%PATH%;C:\Program Files (x86)\GnuWin32\bin
echo %PATH%

WHERE git
if %ERRORLEVEL% NEQ 0 (
echo "GIT does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE node
if %ERRORLEVEL% NEQ 0 (
echo "NODE does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE npm
if %ERRORLEVEL% NEQ 0 (
echo "NPM does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE gulp
if %ERRORLEVEL% NEQ 0 (
echo "GULP does not exist. Please set it up before running this script."
EXIT /B 1
)

:: Below command replaces buildVersion with the appropriate build number from jenkins
sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\"%PARENT_BUILD_VERSION%\"/g" package.json

:: Copy search libraries onto the project root
echo "Copying search libraries"
echo D | xcopy /y "C:\jenkins\workspace\tronlibraries\library" "library"

echo "Running npm install..."
call npm install

call npm i -g gulp-cli

:: Set expiry if required
IF "%EXPIRY_PERIOD%"=="" (
echo "Not setting expiry for the build!"
) else (
echo "Setting expiry to days: %EXPIRY_PERIOD%"
call gulp setExpiry --period %EXPIRY_PERIOD%
)

echo "Running tests, code coverage, linting and building..."
call npm run unpacked-win-x86
60 changes: 60 additions & 0 deletions scripts/build-win64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:: Check to ensure that the VSDev command prompt is in the below location
echo "Starting VSDev Command Prompt"
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"

echo %PATH%

set DISABLE_REBUILD=true

set PATH=%PATH%;C:\Program Files\nodejs\;C:\Program Files\Git\cmd
echo %PATH%

set PATH=%PATH%;C:\Program Files (x86)\GnuWin32\bin
echo %PATH%

WHERE git
if %ERRORLEVEL% NEQ 0 (
echo "GIT does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE node
if %ERRORLEVEL% NEQ 0 (
echo "NODE does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE npm
if %ERRORLEVEL% NEQ 0 (
echo "NPM does not exist. Please set it up before running this script."
EXIT /B 1
)

WHERE gulp
if %ERRORLEVEL% NEQ 0 (
echo "GULP does not exist. Please set it up before running this script."
EXIT /B 1
)

:: Below command replaces buildVersion with the appropriate build number from jenkins
sed -i -e "s/\"buildNumber\"[[:space:]]*\:[[:space:]]*\".*\"/\"buildNumber\":\"%PARENT_BUILD_VERSION%\"/g" package.json

:: Copy search libraries onto the project root
echo "Copying search libraries"
echo D | xcopy /y "C:\jenkins\workspace\tronlibraries\library" "library"

echo "Running npm install..."
call npm install

call npm i -g gulp-cli

:: Set expiry if required
IF "%EXPIRY_PERIOD%"=="" (
echo "Not setting expiry for the build!"
) else (
echo "Setting expiry to days: %EXPIRY_PERIOD%"
call gulp setExpiry --period %EXPIRY_PERIOD%
)

echo "Running tests, code coverage, linting and building..."
call npm run unpacked-win

0 comments on commit 85928f4

Please sign in to comment.