version: "3"

tasks:
  fmt:
    desc: Run gofumpt for all packages
    cmds:
      - gofumpt -w .

  modernize:
    desc: Run modernize for all packages
    cmds:
      - modernize -fix ./...

  lint:
    desc: Run base linters for all packages
    cmds:
      - golangci-lint run

  lint:fix:
    desc: Run base linters for all packages and applies fixes if possible
    cmds:
      - golangci-lint run --fix

  test:
    desc: Run tests for all packages
    cmds:
      - go test ./... -count=1 {{.CLI_ARGS}}
  release:
    desc: Create and push a new tag following semver
    vars:
      NEXT:
        sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
    prompt: "This will release {{.NEXT}}. Continue?"
    preconditions:
      - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
        msg: Not on main branch
      - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
        msg: "Git is dirty"
    cmds:
      - git commit --allow-empty -m "{{.NEXT}}"
      - git tag --annotate --sign -m "{{.NEXT}}" {{.NEXT}} {{.CLI_ARGS}}
      - echo "Pushing {{.NEXT}}..."
      - git push origin main --follow-tags
