#!/usr/bin/env bash set -euo pipefail ts() { date +"%H:%M:%S"; } usage() { cat <<'EOF' Usage: ./build_tools/macos/print_mas_build_cmd.sh [--bundle-id com.dryark.strawberry] [--profile ] What it does: - Tries to auto-pick a provisioning profile for the bundle id - Prints an exact build command you can copy/paste for build_mas_pkg.sh Notes: - This helper intentionally does NOT try to auto-pick signing identities by parsing Apple tool output. Use SHA-1 identities from: ./build_tools/macos/check_signing_identities.sh EOF } if [[ "$(uname -s)" != "Darwin" ]]; then echo "Error: This script is for macOS only." >&2 exit 1 fi script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" repo_root="$(cd -- "${script_dir}/../.." && pwd)" bundle_id="com.dryark.strawberry" profile_path="" codesign_identity="" installer_identity="" while [[ $# -gt 0 ]]; do case "$1" in --bundle-id) bundle_id="${2:-}"; shift 2 ;; --profile) profile_path="${2:-}"; shift 2 ;; --codesign-identity) codesign_identity="${2:-}"; shift 2 ;; --installer-identity) installer_identity="${2:-}"; shift 2 ;; -h|--help) usage; exit 0 ;; *) echo "Unknown arg: $1" >&2; usage; exit 2 ;; esac done if [[ -z "$profile_path" ]]; then # Attempt to auto-select profile using the finder script. finder="${repo_root}/build_tools/macos/find_mas_provisioning_profile.sh" if [[ -x "$finder" ]]; then out="$("$finder" --bundle-id "$bundle_id" 2>/dev/null || true)" # Parse the line after "Recommended profile:" profile_path="$(printf '%s\n' "$out" | awk 'found{print $1; exit} /^Recommended profile:/{found=1} found && $0 ~ /^ \\// {print $1; exit}' | sed 's/^[[:space:]]*//')" fi fi echo "==> [$(ts)] Recommended build command:" echo echo "./build_tools/macos/build_mas_pkg.sh --run --release --clean \\" echo " --codesign-identity \"${codesign_identity:-}\" \\" echo " --installer-identity \"${installer_identity:-}\" \\" if [[ -n "$profile_path" ]]; then echo " --provisionprofile \"${profile_path}\"" else echo " --provisionprofile \"\"" echo echo "Note: could not auto-pick a provisioning profile for bundle id '${bundle_id}'." echo "Run:" echo " ./build_tools/macos/find_mas_provisioning_profile.sh --bundle-id ${bundle_id}" fi