name: Build release binaries

on:
  workflow_dispatch:
  push:
    tags:
      - "v*"

jobs:
  build-release:
    runs-on: "ubuntu-latest"

    steps:
      - name: Set up Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.22.5

      - name: Check out code
        uses: actions/checkout@v2

      - name: Build
        run: make

      - name: Setup minimal git config
        run: |
          git config --global user.email "action@github.com"
          git config --global user.name "GitHub Action"

      - name: Test
        run: make test

      - name: Build binaries
        run: make releases

      - uses: "marvinpinto/action-automatic-releases@latest"
        with:
          repo_token: "${{ secrets.GITHUB_TOKEN }}"
          draft: true
          prerelease: false
          files: dist/*
