name: Build binaries

on:
  push:
    branches: [main]

  pull_request:
    branches: [main]

jobs:
  build-binaries:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        platform:
        - name: linux
          task: build-binaries-linux
        - name: windows
          task: build-binaries-windows
        - name: osx
          task: build-binaries-darwin
        - name: osx-m1
          task: build-binaries-darwin-arm64
        - name: system/390
          task: build-binaries-s390x
        - name: arm
          task: build-binaries-arm64
        - name: powerpc
          task: build-binaries-ppc64le
    name: build binaries for ${{ matrix.platform.name }}
    steps:
    - uses: actions/checkout@v2.4.0
      with:
        submodules: true

    - name: Fetch git tags
      run: |
        git fetch --prune --unshallow --tags

    - uses: actions/setup-go@v2
      with:
        go-version: ^1.17

    - name: Export BRANCH variable
      uses: ./.github/actions/setup-branch

    - name: Install tools
      run: make install-ci

    - name: Build binaries
      run: make ${{ matrix.platform.task }}
