name: Build CLI Developer Snapshot

on:
  pull_request:
  push:
    tags-ignore:
      - 'v*.*.*'

jobs:
  build-cli:
    runs-on: macos-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: 1.16.x
      - name: Print Go Version
        run: go version
      - name: Import GPG key
        id: import_gpg
        uses: crazy-max/ghaction-import-gpg@v3
        with:
          gpg-private-key: ${{ secrets.GPG_KEY }}
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v2
        with:
          version: latest
          args: release --rm-dist --skip-publish --skip-sign
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/upload-artifact@v2
        with:
          name: Upload macOS (amd64) Build Artifact
          path: dist/hcloud-macos-build_darwin_amd64/hcloud
      - uses: actions/upload-artifact@v2
        with:
          name: Upload macOS (arm64) Build Artifact
          path: dist/hcloud-macos-arm-build_darwin_arm64/hcloud
      - uses: actions/upload-artifact@v1
        with:
          name: Upload Windows AMD64 Build Artifact
          path: dist/hcloud-build_windows_amd64/hcloud.exe
      - uses: actions/upload-artifact@v1
        with:
          name: Upload Linux AMD64 Build Artifact
          path: dist/hcloud-build_linux_amd64/hcloud
      - uses: actions/upload-artifact@v1
        with:
          name: Upload FreeBSD AMD64 Build Artifact
          path: dist/hcloud-build_freebsd_amd64/hcloud
