name: Release

on:
  push:
    tags: ["v*"]

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          lfs: true

      - uses: actions/setup-go@v5
        with:
          go-version-file: library/go.mod
          cache-dependency-path: library/go.sum

      - uses: anchore/sbom-action/download-syft@v0

      - uses: goreleaser/goreleaser-action@v6
        with:
          version: "~> v2"
          args: release --clean
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GORELEASER_HOMEBREW_CASK_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
          GORELEASER_SCOOP_GITHUB_TOKEN: ${{ secrets.GH_PAT }}

      - name: Publish gitsocial release
        run: scripts/release.sh "$GITHUB_REF_NAME"
