name: Build

on:
  push:
    branches:
      - main
      - release-0.1x
    tags:
      - v[0-9]+.[0-9]+.[0-9]+*
  pull_request:

permissions:
  contents: read

jobs:
  build:
    name: Build

    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          fetch-depth: 0

      - name: Set up Go
        uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
        with:
          go-version-file: ${{ github.workspace }}/go.mod

      - name: Set up QEMU
        uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0

      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1

      - name: Dry-run GoReleaser
        run: |
          make release-dry-run

      - name: Run debug commands on failure
        if: ${{ failure() }}
        run: |
          echo "--- Environment variables ---"
          env | sort
          echo "--- GO Environment ---"
          go env | sort
          echo "--- Git status ---"
          git status
          echo "--- Docker logs ---"
          docker compose logs
          echo "--- Docker ps ---"
          docker compose ps -a
