#!/bin/bash

script="$( readlink -f "${0}" )"
script_dir="$( dirname "${script}" )"

# shellcheck disable=SC1091
. "${script_dir}/check_version"

# vars defined in `check_version` script
# shellcheck disable=SC2154
if [ "${git_status}" = "releasing" ] || [ "${git_status}" = "released" ]; then
    # shellcheck disable=SC2154
    image_tag="${git_version}"
else
    image_tag="latest"
fi

docker buildx build \
    --pull --push \
    --tag "code.lenaisten.de/lenaisten/advent22:${image_tag}" \
    --platform "linux/amd64" \
    "${script_dir}/.."
