1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-05 02:22:31 +01:00
Radarr/build.sh

309 lines
6.9 KiB
Bash
Raw Normal View History

2015-07-04 14:10:11 +02:00
#! /bin/bash
2019-10-14 22:21:00 +02:00
set -e
2019-10-14 22:21:00 +02:00
outputFolder='_output'
testPackageFolder='_tests'
artifactsFolder="_artifacts";
2015-07-04 14:10:11 +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
sed -i'' -e "s/<string>10.0.0.0<\/string>/<string>$RADARRVERSION<\/string>/g" macOS/Radarr.app/Contents/Info.plist
fi
}
2018-11-23 08:05:47 +01:00
LintUI()
{
ProgressStart 'ESLint'
2019-10-14 22:21:00 +02:00
yarn lint
ProgressEnd 'ESLint'
2018-11-23 08:05:47 +01:00
ProgressStart 'Stylelint'
2019-10-14 22:21:00 +02:00
if [ "$os" = "windows" ]; then
yarn stylelint-windows
else
yarn stylelint-linux
fi
ProgressEnd 'Stylelint'
2018-11-23 08:05:47 +01:00
}
2015-07-04 14:10:11 +02:00
Build()
{
ProgressStart 'Build'
2015-07-04 14:10:11 +02:00
rm -rf $outputFolder
rm -rf $testPackageFolder
2015-07-04 14:10:11 +02:00
slnFile=src/Radarr.sln
2019-10-14 22:21:00 +02:00
if [ $os = "windows" ]; then
platform=Windows
2019-10-14 22:21:00 +02:00
else
platform=Posix
2019-10-14 22:21:00 +02:00
fi
dotnet clean $slnFile -c Debug
dotnet clean $slnFile -c Release
dotnet msbuild -restore $slnFile -p:Configuration=Release -p:Platform=$platform -t:PublishAllRids
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
{
ProgressStart 'yarn install'
yarn install --frozen-lockfile
ProgressEnd 'yarn install'
2019-10-14 22:21:00 +02:00
}
2018-11-23 08:05:47 +01:00
2019-10-14 22:21:00 +02:00
RunGulp()
{
ProgressStart 'Running gulp'
2019-10-14 22:21:00 +02:00
yarn run build --production
ProgressEnd 'Running gulp'
2015-07-04 14:10:11 +02:00
}
PackageFiles()
2015-07-04 14:10:11 +02:00
{
local folder="$1"
local framework="$2"
local runtime="$3"
2015-07-04 14:10:11 +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
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"
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"
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"
cp $folder/Radarr.Mono.* $folder/Radarr.Update
2019-12-05 22:41:55 +01:00
if [ "$framework" = "netcoreapp3.1" ]; then
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
}
PackageMacOS()
2015-07-04 14:10:11 +02:00
{
local framework="$1"
ProgressStart "Creating MacOS Package for $framework"
local folder=$artifactsFolder/macos/$framework/Radarr
PackageFiles "$folder" "$framework" "osx-x64"
2019-10-14 22:21:00 +02:00
if [ "$framework" = "net462" ]; then
echo "Adding Startup script"
cp macOS/Radarr $folder
fi
echo "Removing Service helpers"
rm -f $folder/ServiceUninstall.*
rm -f $folder/ServiceInstall.*
2015-07-04 14:10:11 +02:00
echo "Removing Radarr.Windows"
rm $folder/Radarr.Windows.*
echo "Adding Radarr.Mono to UpdatePackage"
cp $folder/Radarr.Mono.* $folder/Radarr.Update
2019-12-05 22:41:55 +01:00
if [ "$framework" = "netcoreapp3.1" ]; then
cp $folder/Mono.Posix.NETStandard.* $folder/Radarr.Update
cp $folder/libMonoPosixHelper.* $folder/Radarr.Update
fi
2015-07-04 14:10:11 +02:00
ProgressEnd 'Creating MacOS Package'
2015-07-04 14:10:11 +02:00
}
PackageMacOSApp()
2015-07-04 14:10:11 +02:00
{
local framework="$1"
ProgressStart "Creating macOS App Package for $framework"
local folder=$artifactsFolder/macos-app/$framework
rm -rf $folder
mkdir -p $folder
2019-10-14 22:21:00 +02:00
cp -r macOS/Radarr.app $folder
mkdir -p $folder/Radarr.app/Contents/MacOS
echo "Copying Binaries"
cp -r $artifactsFolder/macos/$framework/Radarr/* $folder/Radarr.app/Contents/MacOS
2015-07-04 14:10:11 +02:00
echo "Removing Update Folder"
rm -r $folder/Radarr.app/Contents/MacOS/Radarr.Update
ProgressEnd 'Creating macOS App Package'
2015-07-04 14:10:11 +02:00
}
PackageTests()
{
ProgressStart 'Creating Test Package'
2015-07-04 14:10:11 +02:00
2019-10-14 22:21:00 +02:00
cp test.sh $testPackageFolder/net462/linux-x64/publish
2019-12-05 22:41:55 +01:00
cp test.sh $testPackageFolder/netcoreapp3.1/win-x64/publish
cp test.sh $testPackageFolder/netcoreapp3.1/linux-x64/publish
cp test.sh $testPackageFolder/netcoreapp3.1/osx-x64/publish
2015-07-04 14:10:11 +02:00
rm -f $testPackageFolder/*.log.config
# geckodriver.exe isn't copied by dotnet publish
2019-12-05 22:41:55 +01:00
curl -Lo gecko.zip "https://github.com/mozilla/geckodriver/releases/download/v0.26.0/geckodriver-v0.26.0-win64.zip"
unzip -o gecko.zip
2019-12-05 22:41:55 +01:00
cp geckodriver.exe $testPackageFolder/netcoreapp3.1/win-x64/publish
ProgressEnd 'Creating Test Package'
2015-07-04 14:10:11 +02:00
}
PackageWindows()
2015-07-04 14:10:11 +02:00
{
local framework="$1"
ProgressStart "Creating Windows Package for $framework"
local folder=$artifactsFolder/windows/$framework/Radarr
2019-10-14 22:21:00 +02:00
PackageFiles "$folder" "$framework" "win-x64"
2018-11-23 08:05:47 +01:00
echo "Removing Radarr.Mono"
rm -f $folder/Radarr.Mono.*
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"
cp $folder/Radarr.Windows.* $folder/Radarr.Update
ProgressEnd 'Creating Windows 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
os="windows"
2015-07-04 14:10:11 +02:00
;;
*)
# otherwise use mono
os="posix"
2015-07-04 14:10:11 +02:00
;;
esac
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
LINT=YES
fi
while [[ $# -gt 0 ]]
do
key="$1"
2018-02-12 17:37:11 +01:00
case $key in
2019-10-14 22:21:00 +02:00
--backend)
BACKEND=YES
shift # past argument
;;
--frontend)
FRONTEND=YES
shift # past argument
;;
--packages)
PACKAGES=YES
shift # past argument
;;
2019-10-14 22:21:00 +02:00
--lint)
LINT=YES
shift # past argument
;;
2019-10-14 22:21:00 +02:00
--all)
BACKEND=YES
FRONTEND=YES
PACKAGES=YES
LINT=YES
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
2019-10-14 22:21:00 +02:00
if [ "$BACKEND" = "YES" ];
then
UpdateVersionNumber
Build
PackageTests
fi
2019-10-14 22:21:00 +02:00
if [ "$FRONTEND" = "YES" ];
then
YarnInstall
RunGulp
fi
if [ "$LINT" = "YES" ];
then
2019-10-14 22:21:00 +02:00
if [ -z "$FRONTEND" ];
then
YarnInstall
fi
LintUI
fi
2019-10-14 22:21:00 +02:00
if [ "$PACKAGES" = "YES" ];
then
2019-10-14 22:21:00 +02:00
UpdateVersionNumber
2019-12-05 22:41:55 +01:00
PackageWindows "netcoreapp3.1"
2019-10-14 22:21:00 +02:00
PackageLinux "net462" "linux-x64"
2019-12-05 22:41:55 +01:00
PackageLinux "netcoreapp3.1" "linux-x64"
PackageLinux "netcoreapp3.1" "linux-arm64"
PackageLinux "netcoreapp3.1" "linux-arm"
PackageMacOS "netcoreapp3.1"
PackageMacOSApp "netcoreapp3.1"
fi