#!/usr/bin/env bash set -euo pipefail root_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" build_file="$root_dir/.build.yml" if ! command -v hugo >/dev/null 2>&1; then echo "hugo not found in PATH" >&2 exit 1 fi hugo_version_raw="$(hugo version)" hugo_version="$(printf '%s\n' "$hugo_version_raw" | sed -E 's/^hugo v?([0-9]+\.[0-9]+\.[0-9]+).*/\1/')" if [[ -z "$hugo_version" || "$hugo_version" == "$hugo_version_raw" ]]; then echo "Unable to parse hugo version from: $hugo_version_raw" >&2 exit 1 fi current_version="$(rg -n "HUGO_VERSION:" "$build_file" | sed -E 's/.*HUGO_VERSION:[[:space:]]*//')" if [[ -z "$current_version" ]]; then echo "Unable to read HUGO_VERSION from $build_file" >&2 exit 1 fi if [[ "$hugo_version" == "$current_version" ]]; then echo "Hugo already at $hugo_version" exit 0 fi python3 - <