name: Build

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]

jobs:
  build-binary:
    name: Build Binary
    runs-on: ubuntu-latest
    permissions:
      contents: read
      attestations: write
      id-token: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: "1.25"
          cache: true

      - name: Install dependencies
        run: go mod download

      - name: Verify dependencies
        run: go mod verify

      - name: Build application
        run: |
          go build -v -o bin/tercul-backend ./cmd/api
          ls -la bin/

      - name: Test binary
        run: ./bin/tercul-backend --help || echo "Binary built successfully"

      - name: Upload build artifacts
        uses: actions/upload-artifact@v4
        with:
          name: tercul-backend-binary
          path: bin/
          retention-days: 30
