Skip to content

Commit

Permalink
Build macOS bundle with pyinstaller
Browse files Browse the repository at this point in the history
  • Loading branch information
tnunamak committed Mar 15, 2024
1 parent 3e718f4 commit 30f2caf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 49 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ jobs:
fi
# Staple the notarization ticket to the app bundle
xcrun stapler staple "${{ github.workspace }}/dist/selfie/Selfie.app"
xcrun stapler staple "${{ github.workspace }}/dist/Selfie.app"
# Create the final ZIP archive of the notarized app bundle
ditto -c -k --keepParent "${{ github.workspace }}/dist/selfie/Selfie.app" "${{ github.event.inputs.artifact_name || format('{0}-build', matrix.os) }}.zip"
ditto -c -k --keepParent "${{ github.workspace }}/dist/Selfie.app" "${{ github.event.inputs.artifact_name || format('{0}-build', matrix.os) }}.zip"
- name: Build Non-macOS App
if: runner.os != 'macOS'
Expand Down
Binary file added Selfie.icns
Binary file not shown.
50 changes: 3 additions & 47 deletions scripts/package-macos-app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,12 @@

# Variables
APP_NAME="Selfie"
BUNDLE_IDENTIFIER="com.vana.selfie"
VERSION="0.1.0"
EXECUTABLE_NAME="selfie"
DIST_DIR="dist/selfie"
APP_DIR="${DIST_DIR}/${APP_NAME}.app"
CONTENTS_DIR="${APP_DIR}/Contents"
MACOS_DIR="${CONTENTS_DIR}/MacOS"
RESOURCES_DIR="${CONTENTS_DIR}/Resources"
INFO_PLIST="${CONTENTS_DIR}/Info.plist"

# Create .app directory structure
mkdir -p "${MACOS_DIR}"
mkdir -p "${RESOURCES_DIR}"

# Move the executable
mv "${DIST_DIR}/${EXECUTABLE_NAME}" "${MACOS_DIR}/"

# Move resources and libraries
mv "${DIST_DIR}/_internal" "${RESOURCES_DIR}/"
#mv "${DIST_DIR}/_internal/data" "${RESOURCES_DIR}/data"

# Create Info.plist
cat <<EOF > "${INFO_PLIST}"
<?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>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${BUNDLE_IDENTIFIER}</string>
<key>CFBundleName</key>
<string>${APP_NAME}</string>
<key>CFBundleVersion</key>
<string>${VERSION}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>
EOF

echo "${APP_NAME}.app bundle has been created."

# Developer ID
CERT="Developer ID Application: Corsali, Inc (G7QNBSSW44)"

APP_DIR="dist/Selfie.app"
APP_CONTENTS="${APP_DIR}/Contents"
CERT="Developer ID Application: Corsali, Inc (G7QNBSSW44)"

# Find and sign all executables, dylibs, and .so files
find "$APP_CONTENTS" \( -type f -perm +111 -o -name "*.dylib" -o -name "*.so" \) -exec codesign --force --sign "$CERT" --timestamp --options runtime '{}' +
find "$APP_CONTENTS" -type f \( -perm +111 -o -name "*.dylib" -o -name "*.so" \) -exec codesign --force --sign "$CERT" --timestamp --options runtime '{}' \+

# Sign the app bundle itself
codesign --deep --force --verbose --timestamp --options runtime --sign "$CERT" "${APP_DIR}"
6 changes: 6 additions & 0 deletions selfie.spec
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,9 @@ coll = COLLECT(
upx_exclude=[],
name='selfie',
)

app = BUNDLE(coll,
name='Selfie.app',
icon='Selfie.icns',
bundle_identifier='com.vana.selfie',
)

0 comments on commit 30f2caf

Please sign in to comment.