name: goreleaser

on:
  push:
    tags:
      - "*"

permissions:
  contents: write
  id-token: write
  packages: write

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v5
        with: { go-version: '1.22' }
      - uses: oven-sh/setup-bun@v1

      - run: make build-ui

      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: "securitybrewery"
          password: ${{ secrets.GITHUB_TOKEN }}
      - uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser
          version: '~> v2'
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}