#!/usr/bin/env bash # Shared parsing helpers for resolve-godot-version.sh and resolve-blender-url.sh. # Kept separate from the network calls so the parsing logic can be unit-tested # offline — see test-lib.sh. # Reads a GitHub releases API response (JSON array) on stdin, prints the newest # non-prerelease, non-draft tag with its "-stable" suffix stripped (e.g. "4.7.1"). parse_latest_godot_tag() { jq -r '[.[] | select(.prerelease == false and .draft == false)][0].tag_name' | sed 's/-stable$//' } # Reads the download.blender.org/release/ index HTML on stdin, prints the newest # "X.Y" minor-version directory name (no trailing slash), numerically not # lexicographically (so "4.10" correctly beats "4.2"). parse_latest_blender_minor() { grep -oE 'Blender[0-9]+\.[0-9]+/' | grep -oE '[0-9]+\.[0-9]+' | sort -t. -k1,1n -k2,2n -u | tail -1 } # Reads a Blender minor-version release index HTML on stdin, prints the newest # linux-x64 tarball filename (ignores windows/mac assets and .sha256 sidecars). parse_latest_blender_tarball() { grep -oE 'blender-[0-9.]+-linux-x64\.tar\.xz' | sort -V -u | tail -1 }