# @format

name: Cross Compile

on:
  pull_request:
    branches:
      - master
    paths:
      - go.sum

# This ensures that previous jobs for the PR are canceled when the PR is
# updated.
concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref }}
  cancel-in-progress: true

jobs:
  cross-compile-1:
    name: Cross compile
    needs:
      - lint-job
      - ui-assets
      - reuse-golang-dependencies
      - semgrep-static-code-analysis
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest ]
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
        id: go

      - name: Build on ${{ matrix.os }}
        env:
          GO111MODULE: on
          GOOS: linux
        run: |
          make crosscompile arg1="'linux/ppc64le linux/mips64'"

  cross-compile-2:
    name: Cross compile 2
    needs:
      - lint-job
      - ui-assets
      - reuse-golang-dependencies
      - semgrep-static-code-analysis
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest ]
    steps:
      - name: Check out code
        uses: actions/checkout@v3
      - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
        id: go

      - name: Build on ${{ matrix.os }}
        env:
          GO111MODULE: on
          GOOS: linux
        run: |
          make crosscompile arg1="'linux/arm64 linux/s390x'"

  cross-compile-3:
    name: Cross compile 3
    needs:
      - lint-job
      - ui-assets
      - reuse-golang-dependencies
      - semgrep-static-code-analysis
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest ]
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
        id: go

      - name: Build on ${{ matrix.os }}
        env:
          GO111MODULE: on
          GOOS: linux
        run: |
          make crosscompile arg1="'darwin/amd64 freebsd/amd64'"

  cross-compile-4:
    name: Cross compile 4
    needs:
      - lint-job
      - ui-assets
      - reuse-golang-dependencies
      - semgrep-static-code-analysis
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest ]
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
        id: go

      - name: Build on ${{ matrix.os }}
        env:
          GO111MODULE: on
          GOOS: linux
        run: |
          make crosscompile arg1="'windows/amd64 linux/arm'"

  cross-compile-5:
    name: Cross compile 5
    needs:
      - lint-job
      - ui-assets
      - reuse-golang-dependencies
      - semgrep-static-code-analysis
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        go-version: [ 1.21.x ]
        os: [ ubuntu-latest ]
    steps:
      - name: Check out code
        uses: actions/checkout@v3

      - name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
        uses: actions/setup-go@v3
        with:
          go-version: ${{ matrix.go-version }}
          cache: true
        id: go

      - name: Build on ${{ matrix.os }}
        env:
          GO111MODULE: on
          GOOS: linux
        run: |
          make crosscompile arg1="'linux/386 netbsd/amd64'"
