File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,10 +25,18 @@ jobs:
2525 python -m pip install -e . --group dev --no-cache-dir
2626 - name : Get Python version and Update README.md
2727 run : |
28- python_version=$(grep "requires-python" pyproject.toml | grep -o ">=[^\"]*")
29- python_badge=$(grep '^\!\[Python\]' README.md | sed -n 's/.*\(python-[^)]*\).*/\1/p')
30- new_python_badge="python-$python_version-blue?logo=python"
31- sed -i "s/$python_badge/$new_python_badge/g" README.md
28+ set -euo pipefail
29+ python_version=$(grep -E '^\s*requires-python\s*=' pyproject.toml | grep -oE '>=([^"]+)' | head -n1)
30+ python_badge=$(grep -E '^\!\[Python\]' README.md | sed -n 's/.*\(python-[^)]*\).*/\1/p' | head -n1 || true)
31+ if [[ -z "${python_badge}" ]]; then
32+ echo "Python badge not found in README.md (expected a line starting with '![Python]' containing 'python-...'). Skipping."
33+ exit 0
34+ fi
35+ new_python_badge="python-${python_version}-blue?logo=python"
36+ # Escape for sed replacement (handles '/', '&', etc.)
37+ esc_old=$(printf '%s' "$python_badge" | sed 's/[\/&]/\\&/g')
38+ esc_new=$(printf '%s' "$new_python_badge" | sed 's/[\/&]/\\&/g')
39+ sed -i "s/${esc_old}/${esc_new}/g" README.md
3240 - name : Get interrogate values and Update README.md
3341 run : |
3442 interrogate_val=$(interrogate . | grep -o 'actual: [0-9]*\.[0-9]*' | awk '{print $2}')
You can’t perform that action at this time.
0 commit comments