name: Build

on:
  push:
    branches: [main]
    paths:
      - 'EurKey-macOS.bundle/**'
      - 'scripts/**'
      - 'spec/**'
  pull_request:
    paths:
      - 'EurKey-macOS.bundle/**'
      - 'scripts/**'
      - 'spec/**'

jobs:
  build:
    runs-on: macos-latest
    steps:
      - name: checkout
        uses: actions/checkout@v4

      - name: setup Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.12'

      - name: install Python dependencies
        run: pip install fpdf2

      - name: build bundle
        run: bash scripts/build-bundle.sh

      - name: validate layouts
        run: python3 scripts/validate_layouts.py

      - name: create DMG
        run: bash scripts/create-dmg.sh

      - name: upload DMG
        uses: actions/upload-artifact@v4
        with:
          name: EurKEY-macOS-DMG
          path: build/*.dmg
