2018-08-11 21:52:44 +00:00
|
|
|
# This script requires create-dmg to be installed from https://github.com/sindresorhus/create-dmg
|
2018-07-29 10:38:59 +00:00
|
|
|
BUILD_CONFIG=$1
|
|
|
|
|
|
|
|
fail()
|
|
|
|
{
|
|
|
|
echo "$1" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$BUILD_CONFIG" != "Debug" ] && [ "$BUILD_CONFIG" != "Release" ]; then
|
2019-08-14 01:07:42 +00:00
|
|
|
fail "Invalid build configuration - expected 'Debug' or 'Release'"
|
2018-07-29 10:38:59 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
BUILD_ROOT=$PWD/build
|
|
|
|
SOURCE_ROOT=$PWD
|
|
|
|
BUILD_FOLDER=$BUILD_ROOT/build-$BUILD_CONFIG
|
|
|
|
INSTALLER_FOLDER=$BUILD_ROOT/installer-$BUILD_CONFIG
|
2019-01-06 03:06:00 +00:00
|
|
|
VERSION=`cat $SOURCE_ROOT/app/version.txt`
|
2018-07-29 10:38:59 +00:00
|
|
|
|
2019-12-18 02:10:39 +00:00
|
|
|
if [ "$SIGNING_PROVIDER_SHORTNAME" == "" ]; then
|
|
|
|
SIGNING_PROVIDER_SHORTNAME=$SIGNING_IDENTITY
|
|
|
|
fi
|
|
|
|
if [ "$SIGNING_IDENTITY" == "" ]; then
|
|
|
|
SIGNING_IDENTITY=$SIGNING_PROVIDER_SHORTNAME
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "$SIGNING_IDENTITY" == "" ] || git diff-index --quiet HEAD -- || fail "Signed release builds must not have unstaged changes!"
|
|
|
|
|
2018-07-29 10:38:59 +00:00
|
|
|
echo Cleaning output directories
|
|
|
|
rm -rf $BUILD_FOLDER
|
|
|
|
rm -rf $INSTALLER_FOLDER
|
|
|
|
mkdir $BUILD_ROOT
|
|
|
|
mkdir $BUILD_FOLDER
|
|
|
|
mkdir $INSTALLER_FOLDER
|
|
|
|
|
|
|
|
echo Configuring the project
|
|
|
|
pushd $BUILD_FOLDER
|
2021-12-07 03:04:15 +00:00
|
|
|
qmake $SOURCE_ROOT/moonlight-qt.pro QMAKE_APPLE_DEVICE_ARCHS="x86_64 arm64" || fail "Qmake failed!"
|
2018-07-29 10:38:59 +00:00
|
|
|
popd
|
|
|
|
|
|
|
|
echo Compiling Moonlight in $BUILD_CONFIG configuration
|
|
|
|
pushd $BUILD_FOLDER
|
2020-05-05 00:49:24 +00:00
|
|
|
make -j$(sysctl -n hw.logicalcpu) $(echo "$BUILD_CONFIG" | tr '[:upper:]' '[:lower:]') || fail "Make failed!"
|
2018-07-29 10:38:59 +00:00
|
|
|
popd
|
|
|
|
|
2018-09-04 09:20:00 +00:00
|
|
|
echo Saving dSYM file
|
|
|
|
pushd $BUILD_FOLDER
|
2019-01-06 03:06:00 +00:00
|
|
|
dsymutil app/Moonlight.app/Contents/MacOS/Moonlight -o Moonlight-$VERSION.dsym || fail "dSYM creation failed!"
|
|
|
|
cp -R Moonlight-$VERSION.dsym $INSTALLER_FOLDER || fail "dSYM copy failed!"
|
2018-09-04 09:20:00 +00:00
|
|
|
popd
|
|
|
|
|
2018-08-11 21:52:44 +00:00
|
|
|
echo Creating app bundle
|
2018-07-29 10:38:59 +00:00
|
|
|
EXTRA_ARGS=
|
2018-07-29 22:35:51 +00:00
|
|
|
if [ "$BUILD_CONFIG" == "Debug" ]; then EXTRA_ARGS="$EXTRA_ARGS -use-debug-libs"; fi
|
|
|
|
echo Extra deployment arguments: $EXTRA_ARGS
|
2018-08-11 21:52:44 +00:00
|
|
|
macdeployqt $BUILD_FOLDER/app/Moonlight.app $EXTRA_ARGS -qmldir=$SOURCE_ROOT/app/gui -appstore-compliant || fail "macdeployqt failed!"
|
2018-07-29 22:35:51 +00:00
|
|
|
|
2019-12-18 02:10:39 +00:00
|
|
|
if [ "$SIGNING_IDENTITY" != "" ]; then
|
2019-04-10 01:30:25 +00:00
|
|
|
echo Signing app bundle
|
2019-12-18 02:10:39 +00:00
|
|
|
codesign --force --deep --options runtime --timestamp --sign "$SIGNING_IDENTITY" $BUILD_FOLDER/app/Moonlight.app || fail "Signing failed!"
|
2019-04-10 01:30:25 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-11 21:52:44 +00:00
|
|
|
echo Creating DMG
|
2019-12-18 02:10:39 +00:00
|
|
|
if [ "$SIGNING_IDENTITY" != "" ]; then
|
|
|
|
create-dmg $BUILD_FOLDER/app/Moonlight.app $INSTALLER_FOLDER --identity="$SIGNING_IDENTITY" || fail "create-dmg failed!"
|
2019-08-03 03:40:20 +00:00
|
|
|
else
|
|
|
|
create-dmg $BUILD_FOLDER/app/Moonlight.app $INSTALLER_FOLDER
|
|
|
|
case $? in
|
|
|
|
0) ;;
|
|
|
|
2) ;;
|
|
|
|
*) fail "create-dmg failed!";;
|
|
|
|
esac
|
|
|
|
fi
|
2019-04-10 01:30:25 +00:00
|
|
|
|
|
|
|
if [ "$NOTARY_USERNAME" != "" ] && [ "$NOTARY_PASSWORD" != "" ]; then
|
|
|
|
echo Uploading to App Notary service
|
2019-12-18 02:10:39 +00:00
|
|
|
xcrun altool -t osx -f $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg --primary-bundle-id com.moonlight-stream.Moonlight --notarize-app --username "$NOTARY_USERNAME" --password "$NOTARY_PASSWORD" --asc-provider "$SIGNING_PROVIDER_SHORTNAME" || fail "Notary submission failed"
|
2019-04-10 01:30:25 +00:00
|
|
|
|
|
|
|
echo Waiting 5 minutes for notarization to complete
|
|
|
|
sleep 300
|
|
|
|
|
|
|
|
echo Getting notarization status
|
2019-12-18 02:10:39 +00:00
|
|
|
xcrun altool -t osx --notarization-history 0 --username "$NOTARY_USERNAME" --password "$NOTARY_PASSWORD" --asc-provider "$SIGNING_PROVIDER_SHORTNAME" || fail "Unable to fetch notarization history!"
|
2019-04-10 01:30:25 +00:00
|
|
|
|
|
|
|
echo Stapling notary ticket to DMG
|
|
|
|
xcrun stapler staple -v $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg || fail "Notary ticket stapling failed!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mv $INSTALLER_FOLDER/Moonlight\ $VERSION.dmg $INSTALLER_FOLDER/Moonlight-$VERSION.dmg
|
|
|
|
echo Build successful
|