name: Create release

permissions:
  contents: write

on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout the target Git reference
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Log in to Docker Hub
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Set up Golang
        uses: actions/setup-go@v5
        with:
          go-version-file: go.mod

      - name: Set up Docker buildx
        uses: docker/setup-buildx-action@v3

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          args: release
