name: "Build application"

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  lint-swiftlint:
    runs-on: macos-latest
    steps:
      - name: "Checkout code"
        uses: actions/checkout@v2
      - name: "Run SwiftLint"
        run: swiftlint --reporter github-actions-logging

  build-app:
    runs-on: macos-latest
    needs: lint-swiftlint
    env:
      APP: OpenHaystack
      PROJECT_DIR: OpenHaystack
    defaults:
      run:
        working-directory: ${{ env.PROJECT_DIR }}
    steps:
      - name: "Checkout code"
        uses: actions/checkout@v2
      - name: "Select Xcode 12"
        uses: devbotsxyz/xcode-select@v1
        with:
          version: "12"
      - name: "Archive project"
        run: xcodebuild archive -scheme ${APP} -configuration release -archivePath ${APP}.xcarchive
