build_path=$(cd ../MassEffectModder/build/*-Release/MassEffectModder; pwd)
top_path=$build_path/deploy
bundle_path=$top_path/MassEffectModder.app
mkdir -p $bundle_path/Contents/Resources
cp -R $build_path/MassEffectModder.app $top_path
cp ../MassEffectModder/MassEffectModder/Resources/MEM.icns $bundle_path/Contents/Resources/MassEffectModder.icns
rm -f $bundle_path/Contents/Resources/empty.lproj
mkdir -p $top_path/Licenses
cp ../Licenses/* $top_path/Licenses
cp ../COPYING.txt $top_path/License.txt
version=`grep -E "^VERSION" ../MassEffectModder/MassEffectModder/Program/Version.pri | grep -o -E "[0-9]+"`
year=`grep -E "^MEM_YEAR" ../MassEffectModder/MassEffectModder/Program/Version.pri | grep -o -E "[0-9]+"`
copyright=`grep -E "^QMAKE_TARGET_COPYRIGHT" ../MassEffectModder/MassEffectModder/Program/Version.pri | grep -o -E "\".*\""`
copyright=`echo $copyright | sed -e "s|MEM_YEAR|$year|g" | sed -e 's|\$*||g' | sed -e 's|\"||g'`
sed -i '' "s/Created by Qt/$copyright/" $bundle_path/Contents/Info.plist
sed -i '' "s/NOTE/CFBundleVersion/" $bundle_path/Contents/Info.plist
sed -i '' "s/This file was generated by Qt\/QMake./$version/" $bundle_path/Contents/Info.plist
codesign --force --sign "Apple Development: Pawel Kolodziejski" $bundle_path/Contents/MacOS/MassEffectModder
hdiutil create -volname MassEffectModder -srcfolder $top_path -ov -format UDZO MassEffectModder-macOS-v$version.dmg
