check-rss-template (823B)
1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) 5 tmp_dir=$(mktemp -d) 6 trap 'rm -rf "${tmp_dir}"' EXIT 7 8 hugo_version="${HUGO_VERSION:?HUGO_VERSION must be set}" 9 upstream_template="${tmp_dir}/rss.xml" 10 diff_output="${tmp_dir}/rss.diff" 11 12 curl -fsSL "https://raw.githubusercontent.com/gohugoio/hugo/refs/tags/v${hugo_version}/tpl/tplimpl/embedded/templates/rss.xml" \ 13 -o "${upstream_template}" 14 15 set +e 16 diff "${upstream_template}" "${repo_root}/themes/v2/layouts/_default/rss.xml" >"${diff_output}" 17 diff_status=$? 18 set -e 19 20 if [[ "${diff_status}" -gt 1 ]]; then 21 exit "${diff_status}" 22 fi 23 24 line_count=$(wc -l <"${diff_output}" | tr -d ' ') 25 if [[ "${line_count}" != "7" ]]; then 26 echo "Unexpected RSS template diff line count: ${line_count}" >&2 27 cat "${diff_output}" >&2 28 exit 1 29 fi