Files
Bifrost/scripts/render-readme.sh
T

17 lines
621 B
Bash

#!/usr/bin/env sh
set -eu
version=${1:-$(sh scripts/version.sh)}
printf '%s\n' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$' || { echo 'Invalid plugin version.' >&2; exit 2; }
mkdir -p target
python_bin=${PYTHON:-python3}
"$python_bin" - "$version" <<'PY'
import sys
from pathlib import Path
version = sys.argv[1]
source = Path("README.md").read_text(encoding="utf-8")
if "@PLUGIN_VERSION@" not in source:
raise SystemExit("README.md is missing the plugin version marker.")
Path("target/README.md").write_text(source.replace("@PLUGIN_VERSION@", version), encoding="utf-8")
PY