#!/usr/bin/env bash set -euo pipefail APP_NAME="EMessage" OUTPUT_DIR="./build/bin/${APP_NAME}" APP_BUNDLE="./build/bin/${APP_NAME}.app" # Ensure output directory exists mkdir -p "$OUTPUT_DIR" # 1. Copy the universal executable to specific architecture names UNIVERSAL_EXE="${OUTPUT_DIR}/darwin-universal" if [[ ! -f "$UNIVERSAL_EXE" ]]; then echo "Error: Universal executable not found at ${UNIVERSAL_EXE}" exit 1 fi cp "$UNIVERSAL_EXE" "${OUTPUT_DIR}/darwin-amd64" cp "$UNIVERSAL_EXE" "${OUTPUT_DIR}/darwin-arm64" echo "Created darwin-amd64 and darwin-arm64 from universal executable" # 2. Tar the .app bundle into the output directory as 'darwin-app' if [[ ! -d "$APP_BUNDLE" ]]; then echo "Error: .app bundle not found at ${APP_BUNDLE}" exit 1 fi TARFILE="${OUTPUT_DIR}/darwin-app" tar cf "$TARFILE" -C "$(dirname "$APP_BUNDLE")" "$(basename "$APP_BUNDLE")" echo "Created ${TARFILE}"