name: C/C++ CI

on: [push, pull_request]

jobs:
  linux-x64:
    runs-on: ubuntu-18.04
    steps:
      - uses: actions/checkout@v2
      - name: build-linux-release-x64
        run: |
          git submodule update --init --recursive
          pip3 install --user scons
          scons platform=linux target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $(nproc)
          ldd demo/addons/godot-git-plugin/linux/libgitapi.so
      - uses: actions/upload-artifact@v2
        with:
          name: godot-git-plugin-linux-release-x64-${{ github.sha }}
          if-no-files-found: error
          path: |
            demo/

  windows-x64:
    runs-on: windows-2019
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v2
        with:
          python-version: "3.x"
          architecture: "x64"
      - uses: ilammy/msvc-dev-cmd@v1
      - name: build-windows-release-x64
        run: |
          git submodule update --init --recursive
          pip3 install --user scons
          scons platform=windows target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $env:NUMBER_OF_PROCESSORS
          dumpbin /dependents .\demo\addons\godot-git-plugin\win64\libgitapi.dll
      - uses: actions/upload-artifact@v2
        with:
          name: godot-git-plugin-windows-release-x64-${{ github.sha }}
          if-no-files-found: error
          path: |
            demo/

  macos-x64:
    runs-on: macos-11
    steps:
      - uses: actions/checkout@v2
      - name: build-macos-release-x64
        run: |
          git submodule update --init --recursive
          brew install scons
          scons platform=osx target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json macos_arch=x86_64 macos_ssl_path=/usr/local/opt/openssl@1.1/ use_llvm=yes -j $(sysctl -n hw.logicalcpu)
          otool -L demo/addons/godot-git-plugin/osx/libgitapi.dylib
      - uses: actions/upload-artifact@v2
        with:
          name: godot-git-plugin-macos-release-x64-${{ github.sha }}
          if-no-files-found: error
          path: |
            demo/
