name: tfsec github docker release

on:
  push:
    tags:
      - v*

jobs:
  build:
    name: releasing tfsec
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - uses: actions/setup-go@v2
        with:
          stable: "false"
          go-version: "1.17"
      - run: go version

      - name: Import GPG key
        id: import_gpg
        uses: crazy-max/ghaction-import-gpg@v4.3.0
        with:
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          passphrase: ${{ secrets.GPG_PASSPHRASE }}

      - name: Docker Login
        uses: docker/login-action@v1
        with:
          registry: ghcr.io
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Release
        uses: goreleaser/goreleaser-action@v2
        with:
          version: latest
          args: release --rm-dist -f .goreleaser_github.yml
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
