# https://taskfile.dev

version: '3'

env:
  CURRENT_RELEASE: 0.1.0
  RELEASE_MSG: "First official release of the project"
  GO_VERSION: 1.16.3
  GI_SERVER_PORT: 3500
  REACT_APP_BACKEND_PORT: 3500 #Frontend can't find backend port unless we specify it (for DEV only, does not work when built obv)

tasks:
  build:
    cmds:
      - goreleaser

  install-backend:
    cmds:
      - go install

  install-goreleaser:
    cmds:
      - go install github.com/goreleaser/goreleaser@latest

  install-frontend:
    dir:
      frontend
    cmds:
      - npm install

  install-all:
    deps:
      - install-backend
      - install-frontend
      - install-goreleaser

  release-local:
    deps:
      - build-frontend
    cmds:
      - goreleaser check
      - goreleaser release --snapshot --skip-publish --rm-dist

  release:
    summary: |
      Requires the GITHUB_TOKEN env variable to release to github
      Make sure you push a tag to github if it is a versioned release
    deps:
      - build-frontend
    cmds:
      - git tag -a {{.CURRENT_RELEASE}} -m {{.RELEASE_MSG}}
      - git push origin {{.CURRENT_RELEASE}}
      - goreleaser release

  release-snapshot:
    summary: |
      Requires the GITHUB_TOKEN env variable to release to github
      Releases an unversioned snapshot to github
    deps:
      - build-frontend
    cmds:
      - goreleaser release --snapshot --rm-dist --debug

  run-frontend:
    dir:
      frontend
    cmds:
      - npm run start

  build-frontend:
    dir: frontend
    sources:
      - src/**/*.js
    generates:
      - build/js/*.js
    cmds:
      - npm run build

  run-backend:
    env:
      
      GI_DEVELOPMENT: false
      # TZ: "America/New_York"
    cmds:
      - fiber dev

  run-all:
    deps:
      - build-frontend
      - run-backend
