Skip to content

Commit f549a6b

Browse files
authored
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.
1 parent be6f734 commit f549a6b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

.github/actions/get-llvm/action.yml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,27 @@ runs:
2020
shell: bash
2121
run: |
2222
if [ -z "${{ inputs.version }}" ]; then
23-
# Extract branch from .gitmodules (e.g., "release/18.x")
24-
BRANCH=$(git config -f .gitmodules submodule.llvm.branch)
25-
if [ -n "$BRANCH" ]; then
26-
# Extract version from branch name (e.g., "18.x" from "release/18.x")
27-
VERSION_PREFIX=$(echo "$BRANCH" | sed 's|release/||' | sed 's|\.x$||')
28-
echo "Detected LLVM version prefix from submodule branch: $VERSION_PREFIX"
29-
30-
# Special case: pin LLVM 18 to specific version 18.1.8
31-
if [ "$VERSION_PREFIX" = "18" ]; then
32-
echo "Using pinned version for LLVM 18: llvm-18.1.8"
33-
echo "version_prefix=llvm-18.1.8" >> $GITHUB_OUTPUT
34-
else
35-
echo "version_prefix=llvm-$VERSION_PREFIX" >> $GITHUB_OUTPUT
36-
fi
23+
# Get the full version from the LLVM submodule.
24+
git submodule update --init --recursive
25+
cd llvm
26+
# Try to get the most recent tag (e.g., "llvmorg-18.1.8")
27+
LLVM_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
28+
if [ -n "$LLVM_TAG" ]; then
29+
echo "Detected LLVM version from submodule: $LLVM_TAG"
30+
# Convert "llvmorg-x.y.z" to "llvm-x.y.z"
31+
LLVM_VERSION=$(echo "$LLVM_TAG" | sed 's/^llvmorg-/llvm-/')
32+
echo "Detected LLVM version from submodule: $LLVM_VERSION"
33+
echo "version_prefix=$LLVM_VERSION" >> $GITHUB_OUTPUT
3734
else
38-
echo "No branch found in .gitmodules, will use latest release"
35+
echo "Could not detect LLVM version from submodule, will use latest release"
3936
echo "version_prefix=" >> $GITHUB_OUTPUT
4037
fi
38+
cd ..
4139
else
4240
echo "Using explicitly provided version: ${{ inputs.version }}"
4341
echo "version_prefix=${{ inputs.version }}" >> $GITHUB_OUTPUT
4442
fi
45-
43+
4644
- name: find asset
4745
id: find
4846
uses: actions/github-script@v7

0 commit comments

Comments
 (0)