-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpackage-mac.sh
More file actions
executable file
·48 lines (35 loc) · 1.64 KB
/
package-mac.sh
File metadata and controls
executable file
·48 lines (35 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#Modified from Avalonia's documentation: https://docs.avaloniaui.net/docs/0.10.x/distribution-publishing/macos
set -e
trap 'echo "Error packaging app"; exit 1' ERR
APP_NAME="./src/openlauncher/bin/Release/net8.0/macos-universal/OpenLauncher.app"
PUBLISH_OUTPUT_DIRECTORY="./src/openlauncher/bin/Release/net8.0/macos-universal/."
INFO_PLIST="./info.plist"
ICON_FILE="./src/openlauncher/resources/logo-mac.icns"
if [ -d "$APP_NAME" ]
then
rm -rf "$APP_NAME"
fi
echo "Creating OpenLauncher.app"
rm -r -f "$APP_NAME"
mkdir "$APP_NAME"
mkdir "$APP_NAME/Contents"
mkdir "$APP_NAME/Contents/MacOS"
mkdir "$APP_NAME/Contents/Resources"
cp "$INFO_PLIST" "$APP_NAME/Contents/Info.plist"
cp "$ICON_FILE" "$APP_NAME/Contents/Resources/AppIcon.icns"
for FILE in "$PUBLISH_OUTPUT_DIRECTORY"/*; do
if [ -f "$FILE" ]; then
cp -a "$FILE" "$APP_NAME/Contents/MacOS/."
fi
done
#Get version number from csproj
VERSION_NUMBER=$(sed -n 's/.*<AssemblyVersion>\(.*\)<\/AssemblyVersion>.*/\1/p' ./src/openlauncher/openlauncher.csproj)
#Replace placeholder version with real version number
sed -i -e "s/APP_VERSION_NUMBER/$VERSION_NUMBER/" "$APP_NAME/Contents/Info.plist"
#For whatever reason, sed on macOS creates a backup file when replacing text, so we need to remove it
rm "$APP_NAME/Contents/Info.plist-e"
codesign --sign - --force --deep "./src/openlauncher/bin/Release/net8.0/macos-universal/OpenLauncher.app"
mkdir "$PUBLISH_OUTPUT_DIRECTORY/publish"
echo "Zipping OpenLauncher.app..."
ditto -c -k --keepParent "./src/openlauncher/bin/Release/net8.0/macos-universal/OpenLauncher.app" "./src/openlauncher/bin/Release/net8.0/macos-universal/publish/OpenLauncher.zip"