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: stable
      - uses: docker/setup-qemu-action@v3
      - uses: docker/setup-buildx-action@v3
      - uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GH_PAT }}
      - uses: docker/login-action@v3
        with:
          registry: docker.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - uses: sigstore/cosign-installer@v3.6.0
      - uses: anchore/sbom-action/download-syft@v0.17.2
      - uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser-pro
          version: latest
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GH_PAT }}
          FURY_TOKEN: ${{ secrets.FURY_TOKEN }}
          GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
          COSIGN_PWD: ${{ secrets.COSIGN_PWD }}
          TWITTER_CONSUMER_KEY: ${{ secrets.TWITTER_CONSUMER_KEY }}
          TWITTER_CONSUMER_SECRET: ${{ secrets.TWITTER_CONSUMER_SECRET }}
          TWITTER_ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
          TWITTER_ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
