@ -1,15 +1,15 @@
#! /bin/bash
#! /bin/bash
msBuild = '/c/Program Files (x86)/MSBuild/14.0/Bin'
msBuild = '/c/Program Files (x86)/MSBuild/14.0/Bin'
outputFolder = './_output'
outputFolder = './_output'
outputFolder Mono= './_output_mono '
outputFolder Linux= './_output_linux '
outputFolder Osx= './_output_osx '
outputFolder MacOS= './_output_macos '
outputFolder OsxApp= './_output_osx _app'
outputFolder MacOSApp= './_output_macos _app'
testPackageFolder = './_tests/'
testPackageFolder = './_tests/'
testSearchPattern = '*.Test/bin/x86/Release'
testSearchPattern = '*.Test/bin/x86/Release'
sourceFolder = './src'
sourceFolder = './src'
slnFile = $sourceFolder /NzbDrone .sln
slnFile = $sourceFolder /Sonarr .sln
updateFolder = $outputFolder /NzbDrone .Update
updateFolder = $outputFolder /Sonarr .Update
updateFolderMono = $outputFolder Mono/NzbDrone .Update
updateFolderMono = $outputFolder Linux/Sonarr .Update
nuget = 'tools/nuget/nuget.exe' ;
nuget = 'tools/nuget/nuget.exe' ;
CheckExitCode( )
CheckExitCode( )
@ -23,12 +23,23 @@ CheckExitCode()
return $status
return $status
}
}
ProgressStart( )
{
echo " ##teamcity[blockOpened name=' $1 '] "
echo " ##teamcity[progressStart ' $1 '] "
}
ProgressEnd( )
{
echo " ##teamcity[progressFinish ' $1 '] "
echo " ##teamcity[blockClosed name=' $1 '] "
}
CleanFolder( )
CleanFolder( )
{
{
local path = $1
local path = $1
local keepConfigFiles = $2
local keepConfigFiles = $2
find $path -name "*.transform" -exec rm "{}" \;
find $path -name "*.transform" -exec rm "{}" \;
if [ $keepConfigFiles != true ] ; then
if [ $keepConfigFiles != true ] ; then
@ -67,7 +78,7 @@ BuildWithXbuild()
Build( )
Build( )
{
{
echo "##teamcity[progressStart 'Build']"
ProgressStart 'Build'
rm -rf $outputFolder
rm -rf $outputFolder
@ -82,7 +93,7 @@ Build()
echo "Removing Mono.Posix.dll"
echo "Removing Mono.Posix.dll"
rm $outputFolder /Mono.Posix.dll
rm $outputFolder /Mono.Posix.dll
echo "##teamcity[progressFinish 'Build']"
ProgressEnd 'Build'
}
}
RunGulp( )
RunGulp( )
@ -91,9 +102,9 @@ RunGulp()
yarn install
yarn install
ProgressEnd 'yarn install'
ProgressEnd 'yarn install'
echo "##teamcity[progressStart 'Running gulp']"
ProgressStart 'Running gulp'
CheckExitCode yarn run build --production
CheckExitCode yarn run build --production
echo "##teamcity[progressFinish 'Running gulp']"
ProgressEnd 'Running gulp'
}
}
CreateMdbs( )
CreateMdbs( )
@ -115,79 +126,103 @@ CreateMdbs()
PackageMono( )
PackageMono( )
{
{
echo "##teamcity[progressStart 'Creating Mono Package']"
ProgressStart 'Creating Mono Package'
rm -rf $outputFolderMono
cp -r $outputFolder $outputFolderMono
rm -rf $outputFolderLinux
echo "Copying Binaries"
cp -r $outputFolder $outputFolderLinux
echo "Creating MDBs"
echo "Creating MDBs"
CreateMdbs $outputFolderMono
CreateMdbs $outputFolder Linux
echo "Removing PDBs"
echo "Removing PDBs"
find $outputFolder Mono -name "*.pdb" -exec rm "{}" \;
find $outputFolder Linux -name "*.pdb" -exec rm "{}" \;
echo "Removing Service helpers"
echo "Removing Service helpers"
rm -f $outputFolder Mono /ServiceUninstall.*
rm -f $outputFolder Linux /ServiceUninstall.*
rm -f $outputFolder Mono /ServiceInstall.*
rm -f $outputFolder Linux /ServiceInstall.*
echo "Removing native windows binaries Sqlite, MediaInfo"
echo "Removing native windows binaries Sqlite, MediaInfo"
rm -f $outputFolder Mono /sqlite3.*
rm -f $outputFolder Linux /sqlite3.*
rm -f $outputFolder Mono /MediaInfo.*
rm -f $outputFolder Linux /MediaInfo.*
echo "Adding NzbDrone .Core.dll.config (for dllmap)"
echo "Adding Sonarr .Core.dll.config (for dllmap)"
cp $sourceFolder /NzbDrone.Core/NzbDrone.Core.dll.config $outputFolderMono
cp $sourceFolder /NzbDrone.Core/Sonarr.Core.dll.config $outputFolderLinux
echo "Adding CurlSharp.dll.config (for dllmap)"
echo "Adding CurlSharp.dll.config (for dllmap)"
cp $sourceFolder /NzbDrone.Common/CurlSharp.dll.config $outputFolder Mono
cp $sourceFolder /NzbDrone.Common/CurlSharp.dll.config $outputFolder Linux
echo "Renaming NzbDrone.Console.exe to NzbDrone .exe"
echo "Renaming Sonarr.Console.exe to Sonarr .exe"
rm $outputFolder Mono/NzbDrone .exe*
rm $outputFolder Linux/Sonarr .exe*
for file in $outputFolder Mono/NzbDrone .Console.exe*; do
for file in $outputFolder Linux/Sonarr .Console.exe*; do
mv " $file " " ${ file //.Console/ } "
mv " $file " " ${ file //.Console/ } "
done
done
echo "Removing NzbDrone .Windows"
echo "Removing Sonarr .Windows"
rm $outputFolder Mono/NzbDrone .Windows.*
rm $outputFolder Linux/Sonarr .Windows.*
echo "Adding NzbDrone .Mono to UpdatePackage"
echo "Adding Sonarr .Mono to UpdatePackage"
cp $outputFolder Mono/NzbDrone .Mono.* $updateFolderMono
cp $outputFolder Linux/Sonarr .Mono.* $updateFolderMono
echo "##teamcity[progressFinish 'Creating Mono Package']"
ProgressEnd 'Creating Mono Package'
}
}
PackageOsx ( )
PackageMacOS ( )
{
{
echo "##teamcity[progressStart 'Creating OS X Package']"
ProgressStart 'Creating MacOS Package'
rm -rf $outputFolderOsx
cp -r $outputFolderMono $outputFolderOsx
rm -rf $outputFolderMacOS
mkdir $outputFolderMacOS
echo "Adding Startup script"
cp ./macOS/Sonarr $outputFolderMacOS
dos2unix $outputFolderMacOS /Sonarr
echo "Copying Binaries"
cp -r $outputFolderLinux /* $outputFolderMacOS
echo "Adding sqlite dylibs"
echo "Adding sqlite dylibs"
cp $sourceFolder /Libraries/Sqlite/*.dylib $outputFolderOsx
cp $sourceFolder /Libraries/Sqlite/*.dylib $outputFolder MacOS
echo "Adding MediaInfo dylib"
echo "Adding MediaInfo dylib"
cp $sourceFolder /Libraries/MediaInfo/*.dylib $outputFolderOsx
cp $sourceFolder /Libraries/MediaInfo/*.dylib $outputFolderMacOS
echo "Adding Startup script"
cp ./osx/Sonarr $outputFolderOsx
echo "##teamcity[progressFinish 'Creating OS X Package']"
ProgressEnd 'Creating MacOS Package'
}
}
PackageOsx App( )
PackageMacOS App( )
{
{
echo "##teamcity[progressStart 'Creating OS X App Package']"
ProgressStart 'Creating macOS App Package'
rm -rf $outputFolderOsxApp
mkdir $outputFolderOsxApp
cp -r ./osx/Sonarr.app $outputFolderOsxApp
rm -rf $outputFolderMacOSApp
cp -r $outputFolderOsx $outputFolderOsxApp /Sonarr.app/Contents/MacOS
mkdir $outputFolderMacOSApp
cp -r ./macOS/Sonarr.app $outputFolderMacOSApp
mkdir -p $outputFolderMacOSApp /Sonarr.app/Contents/MacOS
echo "##teamcity[progressFinish 'Creating OS X App Package']"
echo "Adding Startup script"
cp ./macOS/Sonarr $outputFolderMacOSApp /Sonarr.app/Contents/MacOS
dos2unix $outputFolderMacOSApp /Sonarr.app/Contents/MacOS/Sonarr
echo "Copying Binaries"
cp -r $outputFolderLinux /* $outputFolderMacOSApp /Sonarr.app/Contents/MacOS
echo "Adding sqlite dylibs"
cp $sourceFolder /Libraries/Sqlite/*.dylib $outputFolderMacOSApp /Sonarr.app/Contents/MacOS
echo "Adding MediaInfo dylib"
cp $sourceFolder /Libraries/MediaInfo/*.dylib $outputFolderMacOSApp /Sonarr.app/Contents/MacOS
echo "Removing Update Folder"
rm -r $outputFolderMacOSApp /Sonarr.app/Contents/MacOS/Sonarr.Update
ProgressEnd 'Creating macOS App Package'
}
}
PackageTests( )
PackageTests( )
{
{
echo "Packaging Tests"
ProgressStart 'Creating Test Package'
echo "##teamcity[progressStart 'Creating Test Package']"
rm -rf $testPackageFolder
rm -rf $testPackageFolder
mkdir $testPackageFolder
mkdir $testPackageFolder
@ -209,8 +244,8 @@ PackageTests()
CleanFolder $testPackageFolder true
CleanFolder $testPackageFolder true
echo "Adding NzbDrone .Core.dll.config (for dllmap)"
echo "Adding Sonarr .Core.dll.config (for dllmap)"
cp $sourceFolder /NzbDrone.Core/NzbDrone .Core.dll.config $testPackageFolder
cp $sourceFolder /NzbDrone.Core/Sonarr .Core.dll.config $testPackageFolder
echo "Adding CurlSharp.dll.config (for dllmap)"
echo "Adding CurlSharp.dll.config (for dllmap)"
cp $sourceFolder /NzbDrone.Common/CurlSharp.dll.config $testPackageFolder
cp $sourceFolder /NzbDrone.Common/CurlSharp.dll.config $testPackageFolder
@ -218,16 +253,30 @@ PackageTests()
echo "Copying CurlSharp libraries"
echo "Copying CurlSharp libraries"
cp $sourceFolder /ExternalModules/CurlSharp/libs/i386/* $testPackageFolder
cp $sourceFolder /ExternalModules/CurlSharp/libs/i386/* $testPackageFolder
echo "##teamcity[progressFinish 'Creating Test Package']"
ProgressEnd 'Creating Test Package'
}
}
CleanupWindowsPackage( )
CleanupWindowsPackage( )
{
{
echo "Removing NzbDrone.Mono"
ProgressStart 'Cleaning Windows Package'
rm -f $outputFolder /NzbDrone.Mono.*
echo "Removing Sonarr.Mono"
rm -f $outputFolder /Sonarr.Mono.*
echo "Adding Sonarr.Windows to UpdatePackage"
cp $outputFolder /Sonarr.Windows.* $updateFolder
echo "Adding NzbDrone.Windows to UpdatePackage"
ProgressEnd 'Cleaning Windows Package'
cp $outputFolder /NzbDrone.Windows.* $updateFolder
}
PublishArtifacts( )
{
echo "##teamcity[publishArtifacts '_tests/** => tests.zip']"
echo " ##teamcity[publishArtifacts ' $outputFolder /** => Sonarr. $BRANCH . $BUILD_NUMBER .windows.zip!Sonarr'] "
echo " ##teamcity[publishArtifacts ' $outputFolderLinux /** => Sonarr. $BRANCH . $BUILD_NUMBER .linux.tar.gz!Sonarr'] "
echo " ##teamcity[publishArtifacts ' $outputFolderMacOS /** => Sonarr. $BRANCH . $BUILD_NUMBER .macos.tar.gz!Sonarr'] "
echo " ##teamcity[publishArtifacts ' $outputFolderMacOSApp /** => Sonarr. $BRANCH . $BUILD_NUMBER .macos.zip'] "
echo "##teamcity[publishArtifacts 'debian => debian.zip/debian']"
}
}
# Use mono or .net depending on OS
# Use mono or .net depending on OS
@ -245,7 +294,8 @@ esac
Build
Build
RunGulp
RunGulp
PackageMono
PackageMono
PackageOsx
PackageMacOS
PackageOsx App
PackageMacOS App
PackageTests
PackageTests
CleanupWindowsPackage
CleanupWindowsPackage
PublishArtifacts