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