name: fig

on:
  workflow_dispatch:
  push:
    tags:
      - 'v*'

permissions:
  contents: read

jobs:
  fig:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v3
      - uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4
        with:
          go-version: stable
          cache: true
      - run: go run . generate-fig-spec >goreleaser.ts
      - uses: withfig/push-to-fig-autocomplete-action@v1
        with:
          token: ${{ secrets.GH_PAT }}
          autocomplete-spec-name: goreleaser
          spec-path: goreleaser.ts
          integration: commander
