Skip to content

Commit 14837af

Browse files
authored
workflows: Re-implement the get-llvm-version action as a composite action (llvm#101569)
The old version in the llvm/actions repo stopped working after the version variables were moved out of llvm/CMakeLists.txt. Composite actions are more simple and don't require javascript, which is why I reimplemented it as a composite action. This will fix the failing abi checks on the release branch.
1 parent 95b366c commit 14837af

File tree

4 files changed

+127
-15
lines changed

4 files changed

+127
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Get LLVM Version
2+
description: >-
3+
Get the LLVM version from the llvm-project source tree. This action assumes
4+
the llvm-project sources have already been checked out into GITHUB_WORKSPACE.
5+
6+
outputs:
7+
major:
8+
description: LLVM major version
9+
value: ${{ steps.version.outputs.major }}
10+
minor:
11+
description: LLVM minor version
12+
value: ${{ steps.version.outputs.minor }}
13+
patch:
14+
description: LLVM patch version
15+
value: ${{ steps.version.outputs.patch }}
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- name: Get Version
21+
shell: bash
22+
id: version
23+
run: |
24+
for v in major minor patch; do
25+
echo "$v=`llvm/utils/release/get-llvm-version.sh --$v`" >> $GITHUB_OUTPUT
26+
done

.github/workflows/libclang-abi-tests.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ jobs:
3333
ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
3434
ABI_LIBS: ${{ steps.vars.outputs.ABI_LIBS }}
3535
BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
36-
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
37-
LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
38-
LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
36+
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }}
37+
LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }}
38+
LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
3939
steps:
4040
- name: Checkout source
4141
uses: actions/checkout@v4
@@ -44,14 +44,14 @@ jobs:
4444

4545
- name: Get LLVM version
4646
id: version
47-
uses: llvm/actions/get-llvm-version@main
47+
uses: ./.github/workflows/get-llvm-version
4848

4949
- name: Setup Variables
5050
id: vars
5151
run: |
5252
remote_repo='https://github.com/llvm/llvm-project'
53-
if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
54-
major_version=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))
53+
if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then
54+
major_version=$(( ${{ steps.version.outputs.major }} - 1))
5555
baseline_ref="llvmorg-$major_version.1.0"
5656
5757
# If there is a minor release, we want to use that as the base line.
@@ -73,8 +73,8 @@ jobs:
7373
} >> "$GITHUB_OUTPUT"
7474
else
7575
{
76-
echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}"
77-
echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.LLVM_VERSION_MAJOR }}.1.0"
76+
echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}"
77+
echo "BASELINE_REF=llvmorg-${{ steps.version.outputs.major }}.1.0"
7878
echo "ABI_HEADERS=."
7979
echo "ABI_LIBS=libclang.so libclang-cpp.so"
8080
} >> "$GITHUB_OUTPUT"

.github/workflows/llvm-tests.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ jobs:
4343
ABI_HEADERS: ${{ steps.vars.outputs.ABI_HEADERS }}
4444
BASELINE_VERSION_MAJOR: ${{ steps.vars.outputs.BASELINE_VERSION_MAJOR }}
4545
BASELINE_VERSION_MINOR: ${{ steps.vars.outputs.BASELINE_VERSION_MINOR }}
46-
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.LLVM_VERSION_MAJOR }}
47-
LLVM_VERSION_MINOR: ${{ steps.version.outputs.LLVM_VERSION_MINOR }}
48-
LLVM_VERSION_PATCH: ${{ steps.version.outputs.LLVM_VERSION_PATCH }}
46+
LLVM_VERSION_MAJOR: ${{ steps.version.outputs.major }}
47+
LLVM_VERSION_MINOR: ${{ steps.version.outputs.minor }}
48+
LLVM_VERSION_PATCH: ${{ steps.version.outputs.patch }}
4949
steps:
5050
- name: Checkout source
5151
uses: actions/checkout@v4
@@ -54,7 +54,7 @@ jobs:
5454

5555
- name: Get LLVM version
5656
id: version
57-
uses: llvm/actions/get-llvm-version@main
57+
uses: ./.github/workflows/get-llvm-version
5858

5959
- name: Setup Variables
6060
id: vars
@@ -66,14 +66,14 @@ jobs:
6666
# 18.1.0 We want to check 17.0.x
6767
# 18.1.1 We want to check 18.1.0
6868
echo "BASELINE_VERSION_MINOR=1" >> "$GITHUB_OUTPUT"
69-
if [ ${{ steps.version.outputs.LLVM_VERSION_PATCH }} -eq 0 ]; then
69+
if [ ${{ steps.version.outputs.patch }} -eq 0 ]; then
7070
{
71-
echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.LLVM_VERSION_MAJOR }} - 1))"
71+
echo "BASELINE_VERSION_MAJOR=$(( ${{ steps.version.outputs.major }} - 1))"
7272
echo "ABI_HEADERS=llvm-c"
7373
} >> "$GITHUB_OUTPUT"
7474
else
7575
{
76-
echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.LLVM_VERSION_MAJOR }}"
76+
echo "BASELINE_VERSION_MAJOR=${{ steps.version.outputs.major }}"
7777
echo "ABI_HEADERS=."
7878
} >> "$GITHUB_OUTPUT"
7979
fi
+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
#===-- get-llvm-version.sh - Get LLVM Version from sources -----------------===#
3+
#
4+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
# See https://llvm.org/LICENSE.txt for license information.
6+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
#
8+
#===------------------------------------------------------------------------===#
9+
#
10+
# Extract the current LLVM version from the CMake files.
11+
#
12+
#===------------------------------------------------------------------------===#
13+
14+
cmake_file=$(dirname $0)/../../../cmake/Modules/LLVMVersion.cmake
15+
function usage() {
16+
echo "usage: `basename $0`"
17+
echo ""
18+
echo "Calling this script with now options will output the full version: e.g. 19.1.0"
19+
echo " --cmake-file Path to cmake file with the version (default: $cmake_file)
20+
echo " You can use at most one of the following options:
21+
echo " --major Print the major version."
22+
echo " --minor Print the minor version."
23+
echo " --patch Print the patch version."
24+
}
25+
26+
print=""
27+
28+
while [ $# -gt 0 ]; do
29+
case $1 in
30+
--cmake-file )
31+
shift
32+
cmake_file="$1"
33+
;;
34+
--major)
35+
if [ -n "$print" ]; then
36+
echo "Only one of --major, --minor, --patch is allowed"
37+
exit 1
38+
fi
39+
print="major"
40+
;;
41+
--minor)
42+
if [ -n "$print" ]; then
43+
echo "Only one of --major, --minor, --patch is allowed"
44+
exit 1
45+
fi
46+
print="minor"
47+
;;
48+
--patch)
49+
if [ -n "$print" ]; then
50+
echo "Only one of --major, --minor, --patch is allowed"
51+
exit 1
52+
fi
53+
print="patch"
54+
;;
55+
--help | -h | -\? )
56+
usage
57+
exit 0
58+
;;
59+
* )
60+
echo "unknown option: $1"
61+
usage
62+
exit 1
63+
;;
64+
esac
65+
shift
66+
done
67+
68+
major=`grep -o 'LLVM_VERSION_MAJOR[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
69+
minor=`grep -o 'LLVM_VERSION_MINOR[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
70+
patch=`grep -o 'LLVM_VERSION_PATCH[[:space:]]\+\([0-9]\+\)' $cmake_file | grep -o '[0-9]\+'`
71+
72+
case $print in
73+
major)
74+
echo "$major"
75+
;;
76+
minor)
77+
echo "$minor"
78+
;;
79+
patch)
80+
echo "$patch"
81+
;;
82+
*)
83+
echo "$major.$minor.$patch"
84+
;;
85+
esac
86+

0 commit comments

Comments
 (0)