-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild_and_package.sh
74 lines (61 loc) · 2.3 KB
/
build_and_package.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Detect the operating system
OS=$(uname -s)
echo "Detected OS: $OS"
# Clean previous builds
echo "Cleaning previous builds..."
rm -rf build dist InsideImmune.zip InsideImmune.app InsideImmune-MacOS.zip InsideImmune-Linux.zip
# Build the project
echo "Building the project..."
if [[ "$OS" == "Darwin" ]]; then
# macOS build
pyinstaller --noconsole --name InsideImmune --distpath . \
--add-data "assets:assets" --add-data "data:data" --windowed main.py
echo "Creating macOS .app bundle..."
APP_NAME="InsideImmune.app"
mkdir -p "$APP_NAME/Contents/MacOS"
mkdir -p "$APP_NAME/Contents/Resources"
# Copy the binary to the .app bundle
mv InsideImmune "$APP_NAME/Contents/MacOS/InsideImmune"
# Ensure executable permissions
echo "Ensuring executable permissions for macOS binary..."
chmod +x "$APP_NAME/Contents/MacOS/InsideImmune"
# Create Info.plist
cat > "$APP_NAME/Contents/Info.plist" <<EOL
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>InsideImmune</string>
<key>CFBundleDisplayName</key>
<string>InsideImmune</string>
<key>CFBundleExecutable</key>
<string>InsideImmune</string>
<key>CFBundleIdentifier</key>
<string>com.example.insideimmune</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>
EOL
# Package the .app into a zip
echo "Packaging InsideImmune for macOS into InsideImmune-MacOS.zip..."
zip -r InsideImmune-MacOS.zip "$APP_NAME" assets/ data/ README.md
elif [[ "$OS" == "Linux" ]]; then
# Linux build
pyinstaller --onefile --name InsideImmune --distpath . \
--add-data "assets:assets" --add-data "data:data" main.py
# Ensure executable permissions
echo "Ensuring executable permissions for Linux binary..."
chmod +x InsideImmune
# Package the binary into a zip
echo "Packaging InsideImmune for Linux into InsideImmune-Linux.zip..."
zip -r InsideImmune-Linux.zip InsideImmune assets/ data/ README.md
else
echo "Unsupported OS: $OS. This script supports macOS and Linux only."
exit 1
fi
echo "Build and packaging complete!"