#!/bin/bash
# Script to encode your certificate for GitHub Secrets
# Usage: ./encode-cert.sh path/to/Certificates.p12

if [ -z "$1" ]; then
  echo "Usage: $0 path/to/Certificates.p12"
  exit 1
fi

if [ ! -f "$1" ]; then
  echo "Error: File $1 not found"
  exit 1
fi

echo "Encoding certificate to base64..."
base64 -i "$1" | pbcopy
echo "✓ Base64 encoded certificate copied to clipboard!"
echo ""
echo "Next steps:"
echo "1. Go to your GitHub repository → Settings → Secrets and variables → Actions"
echo "2. Create a new secret named: MACOS_CERTIFICATE"
echo "3. Paste the value from your clipboard"
echo "4. Create another secret named: MACOS_CERTIFICATE_PWD"
echo "5. Enter the password you used when exporting the certificate"
