name: Release

on:
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: Set up Go
        uses: actions/setup-go@v5
        with:
          go-version: '1.20.x'

      - name: Check out code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v6
        with:
          version: '~> v2'
          args: release --clean --draft
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  update_release_draft:
    needs: goreleaser
    runs-on: ubuntu-latest
    steps:
      - uses: release-drafter/release-drafter@v6
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
