name: goreleaser

on:
  push:
    tags:
      - 'v*'

permissions:
  id-token: write  # Required for OIDC
  contents: read

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Set up Go
        uses: actions/setup-go@v6
        with:
          go-version: 1.25.x

      - uses: actions/setup-node@v6
        with:
          node-version: '24'
          registry-url: 'https://registry.npmjs.org'

      - name: Update npm
        run: npm install -g npm@latest

      - name: Install Task
        uses: go-task/setup-task@v1

      - name: Install pnpm
        uses: pnpm/action-setup@v4
        with:
          package_json_file: 'website/package.json'
          run_install: 'true'

      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v6
        with:
          distribution: goreleaser-pro
          version: latest
          args: release --clean --draft
        env:
          GITHUB_TOKEN: ${{secrets.GH_PAT}}
          GORELEASER_KEY: ${{secrets.GORELEASER_KEY}}
          CLOUDSMITH_TOKEN: ${{secrets.CLOUDSMITH_TOKEN}}

      - name: Deploy Website
        shell: bash
        run: |
          task website:deploy:prod
