2021-02-09 22:09:13 +01:00
#! /usr/bin/env bash
2019-10-14 22:21:00 +02:00
set -e
2019-09-02 23:03:41 +02:00
2019-10-14 22:21:00 +02:00
outputFolder = '_output'
testPackageFolder = '_tests'
artifactsFolder = "_artifacts" ;
2015-07-04 14:10:11 +02:00
2019-09-02 23:03:41 +02:00
ProgressStart( )
{
echo " Start ' $1 ' "
}
ProgressEnd( )
{
echo " Finish ' $1 ' "
}
UpdateVersionNumber( )
{
if [ " $RADARRVERSION " != "" ] ; then
echo "Updating Version Info"
2019-10-14 22:21:00 +02:00
sed -i'' -e " s/<AssemblyVersion>[0-9.*]\+<\/AssemblyVersion>/<AssemblyVersion> $RADARRVERSION <\/AssemblyVersion>/g " src/Directory.Build.props
sed -i'' -e " s/<AssemblyConfiguration>[\$()A-Za-z-]\+<\/AssemblyConfiguration>/<AssemblyConfiguration> ${ BUILD_SOURCEBRANCHNAME } <\/AssemblyConfiguration>/g " src/Directory.Build.props
2023-05-14 16:18:49 +02:00
sed -i'' -e " s/<string>10.0.0.0<\/string>/<string> $RADARRVERSION <\/string>/g " distribution/osx/Radarr.app/Contents/Info.plist
2019-09-02 23:03:41 +02:00
fi
}
2022-04-12 22:20:24 +02:00
EnableExtraPlatformsInSDK( )
2021-02-09 22:09:13 +01:00
{
2022-04-12 22:20:24 +02:00
SDK_PATH = $( dotnet --list-sdks | grep -P '6\.\d\.\d+' | head -1 | sed 's/\(6\.[0-9]*\.[0-9]*\).*\[\(.*\)\]/\2\/\1/g' )
BUNDLEDVERSIONS = " ${ SDK_PATH } /Microsoft.NETCoreSdk.BundledVersions.props "
if grep -q freebsd-x64 $BUNDLEDVERSIONS ; then
echo "Extra platforms already enabled"
else
echo "Enabling extra platform support"
sed -i.ORI 's/osx-x64/osx-x64;freebsd-x64;linux-x86/' $BUNDLEDVERSIONS
fi
}
2021-02-09 22:09:13 +01:00
2022-04-12 22:20:24 +02:00
EnableExtraPlatforms( )
{
2021-02-09 22:09:13 +01:00
if grep -qv freebsd-x64 src/Directory.Build.props; then
2022-04-12 22:20:24 +02:00
sed -i'' -e "s^<RuntimeIdentifiers>\(.*\)</RuntimeIdentifiers>^<RuntimeIdentifiers>\1;freebsd-x64;linux-x86</RuntimeIdentifiers>^g" src/Directory.Build.props
2021-02-09 22:09:13 +01:00
fi
}
2018-11-23 08:05:47 +01:00
LintUI( )
{
2019-09-02 23:03:41 +02:00
ProgressStart 'ESLint'
2019-10-14 22:21:00 +02:00
yarn lint
2019-09-02 23:03:41 +02:00
ProgressEnd 'ESLint'
2018-11-23 08:05:47 +01:00
2019-09-02 23:03:41 +02:00
ProgressStart 'Stylelint'
2019-10-14 22:21:00 +02:00
if [ " $os " = "windows" ] ; then
yarn stylelint-windows
else
yarn stylelint-linux
fi
2019-09-02 23:03:41 +02:00
ProgressEnd 'Stylelint'
2018-11-23 08:05:47 +01:00
}
2015-07-04 14:10:11 +02:00
Build( )
{
2019-09-02 23:03:41 +02:00
ProgressStart 'Build'
2015-07-04 14:10:11 +02:00
rm -rf $outputFolder
2019-09-02 23:03:41 +02:00
rm -rf $testPackageFolder
2015-07-04 14:10:11 +02:00
2019-12-04 03:18:06 +01:00
slnFile = src/Radarr.sln
2019-10-14 22:21:00 +02:00
if [ $os = "windows" ] ; then
2019-12-04 03:18:06 +01:00
platform = Windows
2019-10-14 22:21:00 +02:00
else
2019-12-04 03:18:06 +01:00
platform = Posix
2019-10-14 22:21:00 +02:00
fi
dotnet clean $slnFile -c Debug
dotnet clean $slnFile -c Release
2020-02-25 23:10:40 +01:00
if [ [ -z " $RID " || -z " $FRAMEWORK " ] ] ;
then
dotnet msbuild -restore $slnFile -p:Configuration= Release -p:Platform= $platform -t:PublishAllRids
else
dotnet msbuild -restore $slnFile -p:Configuration= Release -p:Platform= $platform -p:RuntimeIdentifiers= $RID -t:PublishAllRids
fi
2019-09-02 23:03:41 +02:00
ProgressEnd 'Build'
2015-07-04 14:10:11 +02:00
}
2019-10-14 22:21:00 +02:00
YarnInstall( )
2015-07-04 14:10:11 +02:00
{
2019-09-02 23:03:41 +02:00
ProgressStart 'yarn install'
2020-07-04 05:54:02 +02:00
yarn install --frozen-lockfile --network-timeout 120000
2019-09-02 23:03:41 +02:00
ProgressEnd 'yarn install'
2019-10-14 22:21:00 +02:00
}
2018-11-23 08:05:47 +01:00
2021-04-25 22:31:21 +02:00
RunWebpack( )
2019-10-14 22:21:00 +02:00
{
2021-04-25 22:31:21 +02:00
ProgressStart 'Running webpack'
yarn run build --env production
ProgressEnd 'Running webpack'
2015-07-04 14:10:11 +02:00
}
2019-10-14 22:20:59 +02:00
PackageFiles( )
2015-07-04 14:10:11 +02:00
{
2019-10-14 22:20:59 +02:00
local folder = " $1 "
local framework = " $2 "
local runtime = " $3 "
2015-07-04 14:10:11 +02:00
2019-10-14 22:20:59 +02:00
rm -rf $folder
mkdir -p $folder
cp -r $outputFolder /$framework /$runtime /publish/* $folder
cp -r $outputFolder /Radarr.Update/$framework /$runtime /publish $folder /Radarr.Update
cp -r $outputFolder /UI $folder
2015-07-04 14:10:11 +02:00
2019-10-14 22:20:59 +02:00
echo "Adding LICENSE"
cp LICENSE $folder
}
PackageLinux( )
{
local framework = " $1 "
2019-10-14 22:21:00 +02:00
local runtime = " $2 "
2015-07-04 14:10:11 +02:00
2019-10-14 22:21:00 +02:00
ProgressStart " Creating $runtime Package for $framework "
2015-07-04 14:10:11 +02:00
2019-10-14 22:21:00 +02:00
local folder = $artifactsFolder /$runtime /$framework /Radarr
2015-07-04 14:10:11 +02:00
2019-10-14 22:21:00 +02:00
PackageFiles " $folder " " $framework " " $runtime "
2019-10-14 22:20:59 +02:00
echo "Removing Service helpers"
rm -f $folder /ServiceUninstall.*
rm -f $folder /ServiceInstall.*
2015-07-04 14:10:11 +02:00
2018-11-23 08:05:47 +01:00
echo "Removing Radarr.Windows"
2019-10-14 22:20:59 +02:00
rm $folder /Radarr.Windows.*
2015-07-04 14:10:11 +02:00
2018-11-23 08:05:47 +01:00
echo "Adding Radarr.Mono to UpdatePackage"
2019-10-14 22:20:59 +02:00
cp $folder /Radarr.Mono.* $folder /Radarr.Update
2021-11-22 22:14:28 +01:00
if [ " $framework " = "net6.0" ] ; then
2019-10-14 23:42:30 +02:00
cp $folder /Mono.Posix.NETStandard.* $folder /Radarr.Update
cp $folder /libMonoPosixHelper.* $folder /Radarr.Update
fi
2016-01-16 07:06:33 +01:00
2019-10-14 22:21:00 +02:00
ProgressEnd " Creating $runtime Package for $framework "
2015-07-04 14:10:11 +02:00
}
2019-09-02 23:03:41 +02:00
PackageMacOS( )
2015-07-04 14:10:11 +02:00
{
2019-10-14 22:20:59 +02:00
local framework = " $1 "
2021-11-13 15:15:02 +01:00
local runtime = " $2 "
2019-10-14 22:20:59 +02:00
2021-11-13 15:15:02 +01:00
ProgressStart " Creating MacOS Package for $framework $runtime "
2019-09-02 23:03:41 +02:00
2021-11-13 15:15:02 +01:00
local folder = $artifactsFolder /$runtime /$framework /Radarr
2019-10-14 22:20:59 +02:00
2021-11-13 15:15:02 +01:00
PackageFiles " $folder " " $framework " " $runtime "
2019-09-02 23:03:41 +02:00
2019-10-14 22:20:59 +02:00
echo "Removing Service helpers"
rm -f $folder /ServiceUninstall.*
rm -f $folder /ServiceInstall.*
2015-07-04 14:10:11 +02:00
2019-10-14 22:20:59 +02:00
echo "Removing Radarr.Windows"
rm $folder /Radarr.Windows.*
echo "Adding Radarr.Mono to UpdatePackage"
cp $folder /Radarr.Mono.* $folder /Radarr.Update
2021-11-22 22:14:28 +01:00
if [ " $framework " = "net6.0" ] ; then
2019-10-14 23:42:30 +02:00
cp $folder /Mono.Posix.NETStandard.* $folder /Radarr.Update
cp $folder /libMonoPosixHelper.* $folder /Radarr.Update
fi
2015-07-04 14:10:11 +02:00
2019-09-02 23:03:41 +02:00
ProgressEnd 'Creating MacOS Package'
2015-07-04 14:10:11 +02:00
}
2019-09-02 23:03:41 +02:00
PackageMacOSApp( )
2015-07-04 14:10:11 +02:00
{
2019-10-14 22:20:59 +02:00
local framework = " $1 "
2021-11-13 15:15:02 +01:00
local runtime = " $2 "
2019-10-14 22:20:59 +02:00
2021-11-13 15:15:02 +01:00
ProgressStart " Creating macOS App Package for $framework $runtime "
2019-09-02 23:03:41 +02:00
2021-11-13 15:15:02 +01:00
local folder = " $artifactsFolder / $runtime -app/ $framework "
2019-09-02 23:03:41 +02:00
2019-10-14 22:20:59 +02:00
rm -rf $folder
mkdir -p $folder
2023-05-14 16:18:49 +02:00
cp -r distribution/osx/Radarr.app $folder
2019-10-14 22:20:59 +02:00
mkdir -p $folder /Radarr.app/Contents/MacOS
2019-09-02 23:03:41 +02:00
echo "Copying Binaries"
2021-11-13 15:15:02 +01:00
cp -r $artifactsFolder /$runtime /$framework /Radarr/* $folder /Radarr.app/Contents/MacOS
2015-07-04 14:10:11 +02:00
2019-09-02 23:03:41 +02:00
echo "Removing Update Folder"
2019-10-14 22:20:59 +02:00
rm -r $folder /Radarr.app/Contents/MacOS/Radarr.Update
2019-09-02 23:03:41 +02:00
ProgressEnd 'Creating macOS App Package'
2015-07-04 14:10:11 +02:00
}
2019-10-14 22:20:59 +02:00
PackageWindows( )
2015-07-04 14:10:11 +02:00
{
2019-10-14 22:20:59 +02:00
local framework = " $1 "
2020-11-11 04:56:47 +01:00
local runtime = " $2 "
2019-10-14 22:20:59 +02:00
ProgressStart " Creating Windows Package for $framework "
2020-11-11 04:56:47 +01:00
local folder = $artifactsFolder /$runtime /$framework /Radarr
2019-10-14 22:20:59 +02:00
2020-11-11 04:56:47 +01:00
PackageFiles " $folder " " $framework " " $runtime "
2020-08-25 22:26:45 +02:00
cp -r $outputFolder /$framework -windows/$runtime /publish/* $folder
2019-09-02 23:03:41 +02:00
2018-11-23 08:05:47 +01:00
echo "Removing Radarr.Mono"
2019-10-14 22:20:59 +02:00
rm -f $folder /Radarr.Mono.*
2019-10-14 23:42:30 +02:00
rm -f $folder /Mono.Posix.NETStandard.*
rm -f $folder /libMonoPosixHelper.*
2015-07-04 14:10:11 +02:00
2018-11-23 08:05:47 +01:00
echo "Adding Radarr.Windows to UpdatePackage"
2019-10-14 22:20:59 +02:00
cp $folder /Radarr.Windows.* $folder /Radarr.Update
2019-09-02 23:03:41 +02:00
2019-10-14 22:20:59 +02:00
ProgressEnd 'Creating Windows Package'
2015-07-04 14:10:11 +02:00
}
2020-02-25 23:10:40 +01:00
Package( )
{
local framework = " $1 "
local runtime = " $2 "
local SPLIT
IFS = '-' read -ra SPLIT <<< " $runtime "
case " ${ SPLIT [0] } " in
2021-02-09 22:09:13 +01:00
linux| freebsd*)
2020-02-25 23:10:40 +01:00
PackageLinux " $framework " " $runtime "
; ;
win)
2020-11-11 04:56:47 +01:00
PackageWindows " $framework " " $runtime "
2020-02-25 23:10:40 +01:00
; ;
osx)
2021-11-13 15:15:02 +01:00
PackageMacOS " $framework " " $runtime "
PackageMacOSApp " $framework " " $runtime "
2020-02-25 23:10:40 +01:00
; ;
esac
}
2022-02-16 23:19:42 +01:00
BuildInstaller( )
{
local framework = " $1 "
local runtime = " $2 "
2023-05-14 16:18:49 +02:00
./_inno/ISCC.exe distribution/windows/setup/radarr.iss " //DFramework= $framework " " //DRuntime= $runtime "
2022-02-16 23:19:42 +01:00
}
InstallInno( )
{
ProgressStart "Installing portable Inno Setup"
rm -rf _inno
2024-01-14 19:59:58 +01:00
curl -s --output innosetup.exe " https://files.jrsoftware.org/is/6/innosetup- ${ INNOVERSION :- 6 .2.2 } .exe "
2022-02-16 23:19:42 +01:00
mkdir _inno
./innosetup.exe //portable= 1 //silent //currentuser //dir= .\\ _inno
rm innosetup.exe
ProgressEnd "Installed portable Inno Setup"
}
RemoveInno( )
{
rm -rf _inno
}
2020-02-25 23:10:40 +01:00
PackageTests( )
{
local framework = " $1 "
local runtime = " $2 "
cp test.sh " $testPackageFolder / $framework / $runtime /publish "
rm -f $testPackageFolder /$framework /$runtime /*.log.config
ProgressEnd 'Creating Test Package'
}
2015-07-04 14:10:11 +02:00
# Use mono or .net depending on OS
case " $( uname -s) " in
CYGWIN*| MINGW32*| MINGW64*| MSYS*)
# on windows, use dotnet
2019-10-14 22:20:59 +02:00
os = "windows"
2015-07-04 14:10:11 +02:00
; ;
*)
# otherwise use mono
2019-10-14 22:20:59 +02:00
os = "posix"
2015-07-04 14:10:11 +02:00
; ;
esac
2019-09-02 23:03:41 +02:00
POSITIONAL = ( )
2019-10-14 22:21:00 +02:00
if [ $# -eq 0 ] ; then
echo "No arguments provided, building everything"
BACKEND = YES
FRONTEND = YES
PACKAGES = YES
2022-02-16 23:19:42 +01:00
INSTALLER = NO
2019-10-14 22:21:00 +02:00
LINT = YES
2022-04-12 22:20:24 +02:00
ENABLE_EXTRA_PLATFORMS = NO
ENABLE_EXTRA_PLATFORMS_IN_SDK = NO
2019-10-14 22:21:00 +02:00
fi
2019-09-02 23:03:41 +02:00
while [ [ $# -gt 0 ] ]
do
key = " $1 "
2018-02-12 17:37:11 +01:00
2019-09-02 23:03:41 +02:00
case $key in
2019-10-14 22:21:00 +02:00
--backend)
BACKEND = YES
shift # past argument
; ;
2022-04-12 22:20:24 +02:00
--enable-bsd| --enable-extra-platforms)
ENABLE_EXTRA_PLATFORMS = YES
shift # past argument
; ;
--enable-extra-platforms-in-sdk)
ENABLE_EXTRA_PLATFORMS_IN_SDK = YES
2021-02-09 22:09:13 +01:00
shift # past argument
; ;
2020-02-25 23:10:40 +01:00
-r| --runtime)
RID = " $2 "
shift # past argument
shift # past value
; ;
-f| --framework)
FRAMEWORK = " $2 "
shift # past argument
shift # past value
; ;
2019-10-14 22:21:00 +02:00
--frontend)
FRONTEND = YES
shift # past argument
; ;
--packages)
PACKAGES = YES
2019-09-02 23:03:41 +02:00
shift # past argument
; ;
2022-02-16 23:19:42 +01:00
--installer)
INSTALLER = YES
shift # past argument
; ;
2019-10-14 22:21:00 +02:00
--lint)
LINT = YES
2019-09-02 23:03:41 +02:00
shift # past argument
; ;
2019-10-14 22:21:00 +02:00
--all)
BACKEND = YES
FRONTEND = YES
PACKAGES = YES
LINT = YES
2019-09-02 23:03:41 +02:00
shift # past argument
; ;
*) # unknown option
POSITIONAL += ( " $1 " ) # save it in an array for later
shift # past argument
; ;
esac
done
set -- " ${ POSITIONAL [@] } " # restore positional parameters
2018-02-12 17:31:18 +01:00
2022-04-12 22:20:24 +02:00
if [ " $ENABLE_EXTRA_PLATFORMS_IN_SDK " = "YES" ] ;
then
EnableExtraPlatformsInSDK
fi
2019-10-14 22:21:00 +02:00
if [ " $BACKEND " = "YES" ] ;
2019-09-02 23:03:41 +02:00
then
UpdateVersionNumber
2022-04-12 22:20:24 +02:00
if [ " $ENABLE_EXTRA_PLATFORMS " = "YES" ] ;
2021-02-09 22:09:13 +01:00
then
2022-04-12 22:20:24 +02:00
EnableExtraPlatforms
2021-02-09 22:09:13 +01:00
fi
2019-09-02 23:03:41 +02:00
Build
2020-02-25 23:10:40 +01:00
if [ [ -z " $RID " || -z " $FRAMEWORK " ] ] ;
then
2021-11-22 22:14:28 +01:00
PackageTests "net6.0" "win-x64"
PackageTests "net6.0" "win-x86"
PackageTests "net6.0" "linux-x64"
PackageTests "net6.0" "linux-musl-x64"
PackageTests "net6.0" "osx-x64"
2022-04-12 22:20:24 +02:00
if [ " $ENABLE_EXTRA_PLATFORMS " = "YES" ] ;
2021-02-09 22:09:13 +01:00
then
2021-11-22 22:14:28 +01:00
PackageTests "net6.0" "freebsd-x64"
2022-04-12 22:20:24 +02:00
PackageTests "net6.0" "linux-x86"
2021-02-09 22:09:13 +01:00
fi
2020-02-25 23:10:40 +01:00
else
PackageTests " $FRAMEWORK " " $RID "
fi
2018-02-12 17:31:18 +01:00
fi
2023-07-31 07:34:25 +02:00
if [ [ " $LINT " = "YES" || " $FRONTEND " = "YES" ] ] ;
2019-09-02 23:03:41 +02:00
then
2023-07-31 07:34:25 +02:00
YarnInstall
fi
2022-09-25 09:36:09 +02:00
2023-07-31 07:34:25 +02:00
if [ " $LINT " = "YES" ] ;
then
2019-10-14 22:21:00 +02:00
LintUI
2018-02-12 17:31:18 +01:00
fi
2022-09-25 09:36:09 +02:00
if [ " $FRONTEND " = "YES" ] ;
then
RunWebpack
fi
2019-10-14 22:21:00 +02:00
if [ " $PACKAGES " = "YES" ] ;
2019-09-02 23:03:41 +02:00
then
2019-10-14 22:21:00 +02:00
UpdateVersionNumber
2020-02-25 23:10:40 +01:00
if [ [ -z " $RID " || -z " $FRAMEWORK " ] ] ;
then
2021-11-22 22:14:28 +01:00
Package "net6.0" "win-x64"
Package "net6.0" "win-x86"
Package "net6.0" "linux-x64"
Package "net6.0" "linux-musl-x64"
Package "net6.0" "linux-arm64"
Package "net6.0" "linux-musl-arm64"
Package "net6.0" "linux-arm"
2021-11-13 15:15:02 +01:00
Package "net6.0" "linux-musl-arm"
2021-11-22 22:14:28 +01:00
Package "net6.0" "osx-x64"
2021-11-13 15:15:02 +01:00
Package "net6.0" "osx-arm64"
2022-04-12 22:20:24 +02:00
if [ " $ENABLE_EXTRA_PLATFORMS " = "YES" ] ;
2021-02-09 22:09:13 +01:00
then
2021-11-22 22:14:28 +01:00
Package "net6.0" "freebsd-x64"
2022-04-12 22:20:24 +02:00
Package "net6.0" "linux-x86"
2021-02-09 22:09:13 +01:00
fi
2020-02-25 23:10:40 +01:00
else
Package " $FRAMEWORK " " $RID "
fi
2018-02-12 17:31:18 +01:00
fi
2022-02-16 23:19:42 +01:00
if [ " $INSTALLER " = "YES" ] ;
then
InstallInno
BuildInstaller "net6.0" "win-x64"
BuildInstaller "net6.0" "win-x86"
RemoveInno
fi