name: Release

on:
  push:
    tags:
      - 'v*'
jobs:
  release:
    permissions:
      contents: write # required for creating GH release
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      with:
        fetch-depth: 0
        ref: ${{ github.ref_name}}
    - name: Install Go
      uses: actions/setup-go@v5
      with:
        go-version: 1.24.x
    - name: Test
      run: |
        go test -v -count=1 ./...
    - name: Go Release
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required for creating GH release
      uses: goreleaser/goreleaser-action@v6
      with:
        distribution: goreleaser
        version: "~> v2"
        args: release --clean --verbose
