name: Test Local Signing
on:
workflow_dispatch: # Manual trigger
push:
branches: [ozgur/build]
jobs:
test-local-signing:
runs-on: macos
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Create Test Entitlements
run: |
echo "๐ Creating entitlements file..."
cat > LuckyWorld.entitlements << EOF
com.apple.security.cs.allow-jit
com.apple.security.cs.allow-unsigned-executable-memory
com.apple.security.cs.disable-library-validation
com.apple.security.cs.allow-dyld-environment-variables
com.apple.security.device.audio-input
com.apple.security.device.camera
EOF
echo "โ
Created entitlements file"
cat LuckyWorld.entitlements
shell: bash
- name: Create Test App Bundle
run: |
echo "๐ฆ Creating test app bundle..."
# Create test app bundle structure
TEST_APP_DIR="TestApp.app"
mkdir -p "$TEST_APP_DIR/Contents/MacOS"
# Create a simple test executable
echo '#!/bin/bash
echo "Hello from TestApp!"' > "$TEST_APP_DIR/Contents/MacOS/TestApp"
chmod +x "$TEST_APP_DIR/Contents/MacOS/TestApp"
# Create Info.plist
cat > "$TEST_APP_DIR/Contents/Info.plist" << EOF
CFBundleExecutable
TestApp
CFBundleIdentifier
com.luckyworld.testapp
CFBundleName
TestApp
CFBundlePackageType
APPL
CFBundleShortVersionString
1.0
LSMinimumSystemVersion
10.10
EOF
echo "โ
Created test app bundle"
echo "APP_PATH=$TEST_APP_DIR" >> "$GITHUB_ENV"
# Verify app bundle exists
if [ ! -d "$TEST_APP_DIR" ]; then
echo "โ Error: App bundle not found at $TEST_APP_DIR"
exit 1
fi
echo "๐ App bundle contents:"
ls -la "$TEST_APP_DIR"
shell: bash
- name: Setup Certificate
run: |
echo "๐ Setting up certificate..."
# Create keychain
KEYCHAIN_PATH="$RUNNER_TEMP/app-signing.keychain-db"
KEYCHAIN_PASSWORD="$(openssl rand -base64 12)"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security set-keychain-settings -t 3600 -l "$KEYCHAIN_PATH"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
security list-keychains -s "$KEYCHAIN_PATH" $(security list-keychains | xargs)
# Download and import Apple root certificates
echo "๐ฅ Downloading Apple root certificates..."
curl -o AppleWWDRCAG3.cer https://www.apple.com/certificateauthority/AppleWWDRCAG3.cer
curl -o DeveloperIDG2.cer https://www.apple.com/certificateauthority/DeveloperIDG2.cer
# Check certificate formats
echo "๐ Checking certificate formats..."
file AppleWWDRCAG3.cer
file DeveloperIDG2.cer
# Import Apple WWDRCA certificate
echo "๐ Importing Apple WWDRCA certificate..."
security import AppleWWDRCAG3.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign
# Import Developer ID certificate - try with explicit format
echo "๐ Importing Developer ID certificate..."
security import DeveloperIDG2.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -f pkcs7 || \
security import DeveloperIDG2.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign -f openssl || \
security import DeveloperIDG2.cer -k "$KEYCHAIN_PATH" -T /usr/bin/codesign
# Import developer certificate
echo "๐ Importing developer p12 certificate..."
echo "${{ secrets.MACOS_CERTIFICATE }}" | base64 --decode > certificate.p12
security import certificate.p12 -k "$KEYCHAIN_PATH" -P "${{ secrets.MACOS_CERTIFICATE_PWD }}" -T /usr/bin/codesign
# Set partition list to allow codesign to access keychain without password
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
# Set keychain as default
security default-keychain -s "$KEYCHAIN_PATH"
# Verify certificate
echo "๐ Verifying certificate..."
security find-identity -v -p codesigning "$KEYCHAIN_PATH"
# Cleanup
rm -f certificate.p12 AppleWWDRCAG3.cer DeveloperIDG2.cer
shell: bash
- name: Sign App Bundle
run: |
echo "๐ Signing app bundle..."
# Get the identity hash
IDENTITY=$(security find-identity -v -p codesigning "$KEYCHAIN_PATH" | grep "Developer ID Application" | awk '{print $2}')
if [ -z "$IDENTITY" ]; then
echo "โ Error: No valid Developer ID Application identity found"
exit 1
fi
# Sign the app bundle
codesign --force --options runtime --entitlements LuckyWorld.entitlements --sign "$IDENTITY" --timestamp TestApp.app
# Verify signing
echo "๐ Verifying signature..."
codesign -vvv --deep --strict TestApp.app
# Check entitlements
echo "๐ Checking entitlements..."
codesign -d --entitlements - TestApp.app
shell: bash
- name: Notarize App
run: |
echo "๐ค Notarizing app..."
# Create zip for notarization
ditto -c -k --keepParent TestApp.app TestApp.zip
# Submit for notarization
xcrun notarytool submit TestApp.zip \
--apple-id "${{ secrets.APPLE_NOTARY_USER }}" \
--password "${{ secrets.APPLE_NOTARY_PASSWORD }}" \
--team-id "${{ secrets.APPLE_TEAM_ID }}" \
--wait
# Staple the notarization ticket
xcrun stapler staple TestApp.app
# Verify notarization
spctl --assess --verbose --type exec TestApp.app
shell: bash
- name: Cleanup
if: always()
run: |
echo "๐งน Cleaning up..."
rm -rf TestApp.app TestApp.zip || true
security delete-keychain "$KEYCHAIN_PATH" || true
echo "โ
Cleanup complete"
shell: bash