#!/usr/bin/env bash # Builds the Firezone macOS client for standalone distribution set -euo pipefail source "./scripts/build/lib.sh" # Define needed variables app_profile_id=$(extract_uuid "$STANDALONE_MACOS_APP_PROVISIONING_PROFILE") ne_profile_id=$(extract_uuid "$STANDALONE_MACOS_NE_PROVISIONING_PROFILE") notarize=${NOTARIZE:-"false"} temp_dir="${TEMP_DIR:-$(mktemp -d)}" dmg_dir="$temp_dir/dmg" dmg_path="$temp_dir/Firezone.dmg" staging_dmg_path="$temp_dir/staging.dmg" staging_pkg_path="$temp_dir/staging.pkg" git_sha=${GITHUB_SHA:-$(git rev-parse HEAD)} project_file=swift/apple/Firezone.xcodeproj code_sign_identity="Developer ID Application: Firezone, Inc. (47R2M6779T)" installer_code_sign_identity="Developer ID Installer: Firezone, Inc. (47R2M6779T)" if [ "${CI:-}" = "true" ]; then # Configure the environment for building, signing, and packaging in CI setup_runner \ "$STANDALONE_MACOS_APP_PROVISIONING_PROFILE" \ "$app_profile_id.provisionprofile" \ "$STANDALONE_MACOS_NE_PROVISIONING_PROFILE" \ "$ne_profile_id.provisionprofile" fi # Build and sign echo "Building and signing app..." seconds_since_epoch=$(date +%s) xcodebuild build \ GIT_SHA="$git_sha" \ CODE_SIGN_STYLE=Manual \ CODE_SIGN_IDENTITY="$code_sign_identity" \ PACKET_TUNNEL_PROVIDER_SUFFIX=-systemextension \ OTHER_CODE_SIGN_FLAGS="--timestamp" \ CODE_SIGN_INJECT_BASE_ENTITLEMENTS=NO \ CONFIGURATION_BUILD_DIR="$temp_dir" \ APP_PROFILE_ID="$app_profile_id" \ NE_PROFILE_ID="$ne_profile_id" \ ONLY_ACTIVE_ARCH=NO \ CURRENT_PROJECT_VERSION="$seconds_since_epoch" \ -project "$project_file" \ -skipMacroValidation \ -configuration Release \ -scheme Firezone \ -sdk macosx \ -destination 'platform=macOS' # We also publish a pkg file for MDMs that don't like our DMG (Intune error 0x87D30139) productbuild \ --sign "$installer_code_sign_identity" \ --component "$temp_dir/Firezone.app" \ /Applications \ "$staging_pkg_path" # Create disk image mkdir -p "$dmg_dir/.background" mv "$temp_dir/Firezone.app" "$dmg_dir/Firezone.app" cp "scripts/build/dmg_background.png" "$dmg_dir/.background/background.png" ln -s /Applications "$dmg_dir/Applications" hdiutil create \ -volname "Firezone Installer" \ -srcfolder "$dmg_dir" \ -ov \ -format UDRW \ "$staging_dmg_path" # Mount disk image for customization mount_dir=$(hdiutil attach "$staging_dmg_path" -readwrite -noverify -noautoopen | grep -o "/Volumes/.*") # Embed background image to instruct user to drag app to /Applications osascript <