Skip to content

Commit

Permalink
Refactor functions
Browse files Browse the repository at this point in the history
  • Loading branch information
EyalDelarea committed Jul 14, 2024
1 parent d616c5f commit 4fa8b9d
Showing 1 changed file with 8 additions and 39 deletions.
47 changes: 8 additions & 39 deletions build/apple_release/scripts/darwin-sign-and-notarize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,23 @@

set -e

# Validates the structure of the app template directory.
validate_app_template_structure() {
if [ ! -d "$APP_TEMPLATE_PATH" ]; then
echo "Error: $APP_TEMPLATE_PATH directory does not exist."
exit 1
fi

if [ ! -d "$APP_TEMPLATE_PATH/Contents" ]; then
echo "Error: Contents directory does not exist in $APP_TEMPLATE_PATH."
exit 1
fi

if [ ! -d "$APP_TEMPLATE_PATH/Contents/MacOS" ]; then
echo "Error: MacOS directory does not exist in $APP_TEMPLATE_PATH/Contents."
exit 1
fi

if [ ! -f "$APP_TEMPLATE_PATH/Contents/Info.plist" ]; then
echo "Error: Info.plist file does not exist in $APP_TEMPLATE_PATH/Contents."
exit 1
fi
[ ! -d "$APP_TEMPLATE_PATH" ] && { echo "Error: $APP_TEMPLATE_PATH directory does not exist."; exit 1; }
[ ! -d "$APP_TEMPLATE_PATH/Contents" ] && { echo "Error: Contents directory does not exist in $APP_TEMPLATE_PATH."; exit 1; }
[ ! -d "$APP_TEMPLATE_PATH/Contents/MacOS" ] && { echo "Error: MacOS directory does not exist in $APP_TEMPLATE_PATH/Contents."; exit 1; }
[ ! -f "$APP_TEMPLATE_PATH/Contents/Info.plist" ] && { echo "Error: Info.plist file does not exist in $APP_TEMPLATE_PATH/Contents."; exit 1; }

local app_name_without_extension
app_name_without_extension=$(basename "$APP_TEMPLATE_PATH" .app)
export BINARY_FILE_NAME=$app_name_without_extension

if [ ! -f "$APP_TEMPLATE_PATH/Contents/MacOS/$BINARY_FILE_NAME" ]; then
echo "Error: $BINARY_FILE_NAME not found inside the MacOS folder."
exit 1
fi
[ ! -f "$APP_TEMPLATE_PATH/Contents/MacOS/$BINARY_FILE_NAME" ] && { echo "Error: $BINARY_FILE_NAME not found inside the MacOS folder."; exit 1; }
}

# Validates input environment variables.
validate_inputs() {
if [ -z "$APPLE_CERT_DATA" ]; then
echo "Error: Missing APPLE_CERT_DATA environment variable."
exit 1
fi

if [ -z "$APPLE_CERT_PASSWORD" ]; then
echo "Error: Missing APPLE_CERT_PASSWORD environment variable."
exit 1
fi

if [ -z "$APPLE_TEAM_ID" ]; then
echo "Error: Missing APPLE_TEAM_ID environment variable."
exit 1
fi
[ -z "$APPLE_CERT_DATA" ] && { echo "Error: Missing APPLE_CERT_DATA environment variable."; exit 1; }
[ -z "$APPLE_CERT_PASSWORD" ] && { echo "Error: Missing APPLE_CERT_PASSWORD environment variable."; exit 1; }
[ -z "$APPLE_TEAM_ID" ] && { echo "Error: Missing APPLE_TEAM_ID environment variable."; exit 1; }

validate_app_template_structure
}
Expand Down

0 comments on commit 4fa8b9d

Please sign in to comment.