# https://taskfile.dev

version: '3'

vars:
  VERSION: v0
  DEPLOY_HOST: racker
  GOARCH: amd64

tasks:
  build-bin:
    cmds:
      - CGO_ENABLED=0 GOARCH={{ .GOARCH }} go build -o bin/incus-sentinel.{{ .VERSION }}.linux.{{ .GOARCH }} main.go
    silent: false
  build:
    cmds:
    - mkdir -p bin
    - task: build-bin
      vars:
        GOARCH: arm64
    - task: build-bin
      vars:
        GOARCH: amd64
  deploy:
    cmds:
    - scp bin/incus-sentinel.{{ .VERSION }}.linux.{{ .GOARCH }} {{ .DEPLOY_HOST }}:/usr/local/bin/incus-sentinel.tmp
    - ssh {{ .DEPLOY_HOST }} mv /usr/local/bin/incus-sentinel.tmp /usr/local/bin/incus-sentinel
    - ssh {{ .DEPLOY_HOST }} systemctl restart incus-sentinel
  deploy-home:
    cmds:
    - task: build
    - task: deploy
      vars:
        DEPLOY_HOST: racker
        GOARCH: arm64
    - task: deploy
      vars:
        DEPLOY_HOST: racker1
        GOARCH: arm64
    - task: deploy
      vars:
        DEPLOY_HOST: deimos
        GOARCH: amd64
  deploy-rosti:
    cmds:
    - task: build
    - task: deploy
      vars:
        DEPLOY_HOST: rosti-mars
        GOARCH: amd64
    - task: deploy
      vars:
        DEPLOY_HOST: rosti-merkur
        GOARCH: amd64
    - task: deploy
      vars:
        DEPLOY_HOST: rosti-io
        GOARCH: amd64
    - task: deploy
      vars:
        DEPLOY_HOST: rosti-venus
        GOARCH: amd64