VERSION := "0.3.0"
PATCH := "1"

set dotenv-load := true

# Lint with shellcheck
lint:
  shellcheck ./bin/coprctl

# Open a shell with bin in the PATH
shell:
  PATH="$(pwd)/bin:${PATH}" bash --login

# Build the Docker image
build-docker:
  docker build -t 'coprctl:{{VERSION}}' .
  docker tag 'coprctl:{{VERSION}}' 'coprctl:latest'
  docker tag 'coprctl:{{VERSION}}' 'jfhbrook/coprctl:{{VERSION}}'
  docker tag 'jfhbrook/coprctl:{{VERSION}}' 'jfhbrook/coprctl:latest'

#
# Publishing
#

check_tap:
  if [ ! -d "${HOMEBREW_TAP}" ]; then echo "A HOMEBREW_TAP is required to publish."; exit 1; fi

tag:
  tito tag --use-version '{{VERSION}}'

bundle:
  tar -czf coprctl-{{VERSION}}.tar.gz bin LICENSE README.md

push:
  git push origin --follow-tags

gh-release:
  bash ./scripts/release.sh '{{VERSION}}' '{{PATCH}}'

publish-docker:
  docker push 'jfhbrook/coprctl:{{VERSION}}'
  docker push jfhbrook/coprctl:latest

apply-homebrew:
  bash ./scripts/apply-homebrew.sh '{{VERSION}}' '{{PATCH}}'

apply-copr:
  coprctl apply -f ./package.yml

build-copr:
  copr build-package jfhbrook/joshiverse --name 'coprctl'

# Publish the release on GitHub, Homebrew, Docker and Copr
publish: check_tap tag push bundle gh-release apply-homebrew publish-docker apply-copr build-copr
