#!/bin/bash # Git repository REPO="https://gitlab.com/libvirt/libvirt.git" # Get tag name using 'git ls-remote' TAG_NAME=$(git ls-remote --exit-code --refs --tags --sort='v:refname' "$REPO" | cut -d'/' -f3 | grep -E '^v[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}$' | tail -n1) # Trim 'v' character in TAG_NAME variable VERSION=$(echo "$TAG_NAME" | tr -d 'v') echo "$VERSION"