Infer full LLVM release version from git's tags (#437)

The helps to remove special casing from actions and will make future
LLVM updates smoother.
This commit is contained in:
kvpanch
2025-12-22 16:23:29 -05:00
committed by GitHub
parent be6f734cfc
commit f549a6b031
+13 -15
View File
@@ -20,24 +20,22 @@ runs:
shell: bash shell: bash
run: | run: |
if [ -z "${{ inputs.version }}" ]; then if [ -z "${{ inputs.version }}" ]; then
# Extract branch from .gitmodules (e.g., "release/18.x") # Get the full version from the LLVM submodule.
BRANCH=$(git config -f .gitmodules submodule.llvm.branch) git submodule update --init --recursive
if [ -n "$BRANCH" ]; then cd llvm
# Extract version from branch name (e.g., "18.x" from "release/18.x") # Try to get the most recent tag (e.g., "llvmorg-18.1.8")
VERSION_PREFIX=$(echo "$BRANCH" | sed 's|release/||' | sed 's|\.x$||') LLVM_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
echo "Detected LLVM version prefix from submodule branch: $VERSION_PREFIX" if [ -n "$LLVM_TAG" ]; then
echo "Detected LLVM version from submodule: $LLVM_TAG"
# Special case: pin LLVM 18 to specific version 18.1.8 # Convert "llvmorg-x.y.z" to "llvm-x.y.z"
if [ "$VERSION_PREFIX" = "18" ]; then LLVM_VERSION=$(echo "$LLVM_TAG" | sed 's/^llvmorg-/llvm-/')
echo "Using pinned version for LLVM 18: llvm-18.1.8" echo "Detected LLVM version from submodule: $LLVM_VERSION"
echo "version_prefix=llvm-18.1.8" >> $GITHUB_OUTPUT echo "version_prefix=$LLVM_VERSION" >> $GITHUB_OUTPUT
else
echo "version_prefix=llvm-$VERSION_PREFIX" >> $GITHUB_OUTPUT
fi
else else
echo "No branch found in .gitmodules, will use latest release" echo "Could not detect LLVM version from submodule, will use latest release"
echo "version_prefix=" >> $GITHUB_OUTPUT echo "version_prefix=" >> $GITHUB_OUTPUT
fi fi
cd ..
else else
echo "Using explicitly provided version: ${{ inputs.version }}" echo "Using explicitly provided version: ${{ inputs.version }}"
echo "version_prefix=${{ inputs.version }}" >> $GITHUB_OUTPUT echo "version_prefix=${{ inputs.version }}" >> $GITHUB_OUTPUT