name: release
on:
  # Test that it works on pull_request; goreleaser goes into snapshot mode if not a tag.
  pull_request:
  push:
    tags:
      - v*

permissions:
  # goreleaser writes to the releases api
  contents: write

jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: actions/setup-go@v2
        with:
          go-version: '^1.x'
      - uses: goreleaser/goreleaser-action@v2
        with:
          version: latest
          args: release --rm-dist
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
