name: Build Go Binaries
on:
    push:
        branches:
            - main

jobs:
    build:
        runs-on: docker
        steps:
          - name: Checkout
            uses: actions/checkout@v2

          - name: Set up Go
            uses: actions/setup-go@v5
            with:
              go-version: 1.23

          - name: Cross-Compile
            run: |
              mkdir -p dist
              for GOOS in linux windows darwin; do
                for GOARCH in arm64 amd64; do
                  OUTPUT="dist/myapp_${GOOS}_${GOARCH}"
                  echo "Building ${OUTPUT}"
                  if [ "$GOOS" = "windows" ]; then
                    OUTPUT="${OUTPUT}.exe"
                  fi
                  GOOS=$GOOS GOARCH=$GOARCH go build -o $OUTPUT ./cmd/main
                done
              done

          - name: Upload Artifact
            uses: actions/upload-artifact@v4
            with:
              name: flo_download-binaries
              path: dist