# iOS CircleCI 2.1 configuration file
version: 2.1
jobs:
  build:
    macos:
      xcode: "14.2.0"

    steps:
      - checkout

      - run:
          name: Set timezone and check current datetime
          command: |
            sudo systemsetup -settimezone Europe/Warsaw
            echo "Today is $(date +"%Y-%m-%d %T")"

      - run:
          name: Install libpcap
          command: |
            HOMEBREW_NO_AUTO_UPDATE=1 brew install libpcap

      - run:
          name: Build ubridge
          command: |
            cc -v
            make

      - run:
          name: Verify ubridge build
          command: |
            ./ubridge -v

      - run:
          name: Gather artifacts
          command: |
            mkdir artifacts
            mv ubridge artifacts/ubridge-osx

      - store_artifacts:
          path: artifacts
          destination: artifacts

      - run:
          name: Upload nightly builds to SF
          command: |
            if [ -n "${RUN_NIGHTLY_BUILD}" ]; then
              ssh-keyscan -H frs.sourceforge.net >> ~/.ssh/known_hosts
              echo "mkdir \"/home/frs/project/gns-3/Nightly Builds/$(date +"%Y-%m-%d")/\"" | sftp gns3build@frs.sourceforge.net
              echo -ne "
                cd \"/home/frs/project/gns-3/Nightly Builds/$(date +"%Y-%m-%d")/\"
                put \"artifacts/ubridge-osx\"
              " | sftp gns3build@frs.sourceforge.net
            fi

