---
version: '3'

tasks:
  bin:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: bin
          PACKAGE: github.com/marcosnils/bin@latest

  bundle:
    deps:
      - bin
      - golangci-lint
      - goreleaser
      - minio
      - nfpm
      - ots
      - pup

  clean:
    cmds:
      - rm -rf "$GOPATH/pkg" "$GOPATH/src"
    status:
      - '[ -z "$GOPATH" ]'

  gitomatic:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: gitomatic
          PACKAGE: github.com/muesli/gitomatic@latest

  goconvey:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: goconvey
          PACKAGE: github.com/smartystreets/goconvey@latest

  golangci-lint:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: golangci-lint
          PACKAGE: github.com/golangci/golangci-lint/cmd/golangci-lint@v1.45.0

  goofys:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: goofys
          PACKAGE: github.com/kahing/goofys@latest

  goreleaser:
    run: once
    tags:
      - semantic
    cmds:
      - task: install:go
        vars:
          BIN_NAME: goreleaser
          PACKAGE: github.com/goreleaser/goreleaser@latest

  gotestsum:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: gotestsum
          PACKAGE: gotest.tools/gotestsum@latest

  gum:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: gum
          PACKAGE: github.com/charmbracelet/gum@latest

  install:go:
    vars:
      BIN: '{{.BIN_NAME}}'
    run: when_changed
    log:
      error: Failed to install `{{.PACKAGE}}` with Go
      start: Installing Go package named `{{.PACKAGE}}`
      success: Successfully installed `{{.PACKAGE}}`
    cmds:
      - task: :install:software:go
      - go install {{.PACKAGE}}
    status:
      - type {{.BIN}} > /dev/null

  minio:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: mc
          PACKAGE: github.com/minio/mc@latest

  misspell:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: misspell
          PACKAGE: github.com/client9/misspell/cmd/misspell@latest

  nfpm:
    run: once
    tags:
      - semantic
    cmds:
      - task: install:go
        vars:
          BIN_NAME: nfpm
          PACKAGE: github.com/goreleaser/nfpm/v2/cmd/nfpm@latest

  node-prune:
    run: once
    tags:
      - semantic
    cmds:
      - task: install:go
        vars:
          BIN_NAME: node-prune
          PACKAGE: github.com/tj/node-prune@latest

  ots:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: ots
          PACKAGE: github.com/sniptt-official/ots@latest

  pup:
    run: once
    cmds:
      - task: install:go
        vars:
          BIN_NAME: pup
          PACKAGE: github.com/ericchiang/pup@latest
