name: Continuous Build MacOS

on:
  workflow_dispatch:
  push:
    branches:
      - main
    tags-ignore:
      - '*.*'
    paths:
      - 'src/**'
      - '!src/linux/**'
      - '!src/freebsd/**'
      - '!src/netbsd/**'
      - '!src/openbsd/**'
      - 'include/**'
      - 'Makefile'
      - '.github/workflows/continuous-build-macos.yml'
  pull_request:
    branches:
      - main
    paths:
      - 'src/**'
      - '!src/linux/**'
      - '!src/freebsd/**'
      - '!src/netbsd/**'
      - '!src/openbsd/**'
      - 'include/**'
      - 'Makefile'
      - '.github/workflows/continuous-build-macos.yml'

jobs:
  build-macos:
    strategy:
      matrix:
        os:
         # - {runner: 'macos-13', version: 'Ventura'}
          - {runner: 'macos-14', version: 'Sonoma'}
          - {runner: 'macos-15', version: 'Sequoia'}
    runs-on: ${{ matrix.os.runner }}
    steps:
      - uses: maxim-lobanov/setup-xcode@v1
        with:
          xcode-version: latest-stable

      - uses: actions/checkout@v6

      - name: Install build tools
        run: |
          export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
          brew update --quiet
          brew install --force --overwrite gcc@15 lowdown

      - name: Compile
        run: |
          make CXX=$(brew --prefix)/bin/g++-15
          GIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
          mv bin/btop bin/btop-arm64-${{ matrix.os.runner }}-${{ matrix.os.version }}-$GIT_HASH
          ls -alh bin

      - uses: actions/upload-artifact@v5
        with:
          name: btop-arm64-${{ matrix.os.runner }}-${{ matrix.os.version }}
          path: 'bin/*'
