name: Build IPA

on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
  workflow_dispatch:

jobs:
  build:
    runs-on: macos-latest
    
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      
    - name: Setup Xcode
      uses: maxim-lobanov/setup-xcode@v1
      with:
        xcode-version: '15.0'
        
    - name: Build Archive
      run: |
        xcodebuild -project MobileMkch.xcodeproj \
          -scheme MobileMkch \
          -configuration Release \
          -destination 'generic/platform=iOS' \
          -archivePath MobileMkch.xcarchive \
          archive
          
    - name: Create Payload
      run: |
        mkdir -p Payload
        cp -r MobileMkch.xcarchive/Products/Applications/MobileMkch.app Payload/
        
    - name: Create IPA
      run: |
        zip -r MobileMkch.ipa Payload/
        
    - name: Upload IPA
      uses: actions/upload-artifact@v4
      with:
        name: MobileMkch-ipa
        path: MobileMkch.ipa 