#!/usr/bin/env bash

set -euo pipefail

if [ "${GITHUB_ACTIONS:-}" = "true" ]; then
    git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
    git config --local user.name "GitHub Action"

    VERSION="$(uvx hatch version)"

    if [ "refs/tags/${VERSION}" != "${GITHUB_REF}" ] ; then
        echo "The tag ${VERSION} does not match the GitHub ref ${GITHUB_REF}"
        exit 1
    fi
fi

uv publish
uv run mkdocs gh-deploy --force

echo "Done! 🎉"
