name: goreleaser

on:
  push:
    tags:
      - "*"

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

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v6
        with: { go-version: '1.25' }
      - uses: oven-sh/setup-bun@v2

      - run: make install-ui build-ui

      - uses: docker/login-action@v4
        with:
          registry: ghcr.io
          username: "securitybrewery"
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Run GoReleaser
        run: |
          docker run --rm --privileged \
            -v `pwd`:/go/src/github.com/SecurityBrewery/catalyst \
            -v /var/run/docker.sock:/var/run/docker.sock \
            -w /go/src/github.com/SecurityBrewery/catalyst \
            -e CGO_ENABLED=1 \
            -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
            ghcr.io/goreleaser/goreleaser-cross:v1.25.1 \
            release --clean
