#!/usr/bin/env bash

set -euo pipefail

commit_sha="${1:-HEAD}"
tag="$(date '+%Y-%m-%d-%H.%M.%S')"

echo "Tagging commit $(git rev-parse "${commit_sha}") as ${tag}."
echo ""

# Tag the appropriate commit and push to the remote.
git tag "${tag}" "${commit_sha}"
git push origin "refs/tags/${tag}" --no-verify