Skip to content

Commit b830170

Browse files
committed
Add component versions to releases
1 parent 65aa3ca commit b830170

File tree

8 files changed

+131
-2
lines changed

8 files changed

+131
-2
lines changed

.github/workflows/build-toolchain.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ jobs:
168168
with:
169169
use-built-toolchain: true
170170

171+
generate-version-info:
172+
needs: [build-llvm, build-sysroot]
173+
uses: ./.github/workflows/version-info.yml
174+
with:
175+
use-built-toolchain: true
176+
171177
release:
172178
needs: test-bazel-rules
173179
name: Release
@@ -181,14 +187,20 @@ jobs:
181187
pattern: '{llvm,sysroot,compiler-rt}-*'
182188
path: artifacts/
183189
merge-multiple: True
190+
- name: Download version info
191+
uses: actions/download-artifact@v4
192+
with:
193+
name: version-info
184194
- run: |
185195
git config user.name github-actions
186196
git config user.email [email protected]
197+
- run: |
198+
cat .github/workflows/notes/toolchain.md artifacts/version_info.md > notes.md
187199
- run: |
188200
VERSION=toolchain-$(date +%Y.%m.%d)
189201
if [ "${{ inputs.build_number }}" != "0" ]; then VERSION="$VERSION-${{ inputs.build_number }}"; fi
190202
git tag -a $VERSION -m "Release $VERSION"
191203
git push --tags
192-
gh release create $VERSION artifacts/*
204+
gh release create -F notes.md $VERSION artifacts/*
193205
env:
194206
GH_TOKEN: ${{ github.token }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This is a toolchain release.
2+
If you are looking for the Bazel or CMake integrations, please look for one of those releases instead.
3+
4+
This release contains the following:
5+
* LLVM compiler toolchain
6+
* Linux sysroots
7+
* Linux compiler-rt (for cross-compiling sanitizers from non-Linux hosts)
8+
9+
This release contains the following components:

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,14 @@ jobs:
4343
with:
4444
ref: ${{ needs.tag.outputs.version }}
4545

46+
generate-version-info:
47+
needs: [tag]
48+
uses: ./.github/workflows/version-info.yml
49+
with:
50+
ref: ${{ needs.tag.outputs.version }}
51+
4652
release:
47-
needs: [tag, test-bazel, test-cmake]
53+
needs: [tag, test-bazel, test-cmake, generate-version-info]
4854
uses: bazel-contrib/.github/.github/workflows/[email protected]
4955
with:
5056
bazel_test_command: true || # we already tested the tag

.github/workflows/release_prep.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ FetchContent_MakeAvailable(PortableCcToolchain)
3939
4040
To enable the toolchain, set \`CMAKE_TOOLCHAIN_FILE\` to \`portable_cc_toolchain/toolchain.cmake\`.
4141
For cross-compiling, set \`CMAKE_TOOLCHAIN_FILE\` to \`portable_cc_toolchain/<target>.cmake\` (e.g. \`aarch64-unknown-linux-gnu.cmake\`)
42+
43+
These integrations use the following components:
4244
EOF
45+
46+
cat artifacts/version_info.md

.github/workflows/version-info.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Test bazel rules
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
use-built-toolchain:
7+
type: boolean
8+
ref:
9+
type: string
10+
11+
jobs:
12+
13+
test-cmake-rules:
14+
name: generate version info
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
ref: ${{ inputs.ref }}
20+
- name: Download built toolchain
21+
uses: actions/download-artifact@v4
22+
if: ${{ inputs.use-built-toolchain }}
23+
with:
24+
pattern: '{llvm-x86_64-unknown-linux-gnu,sysroot-x86_64-unknown-linux-gnu,compiler-rt-linux}'
25+
merge-multiple: True
26+
- name: Configure built toolchain
27+
if: ${{ inputs.use-built-toolchain }}
28+
shell: bash
29+
run: |
30+
echo "PORTABLE_CC_TOOLCHAIN_LLVM=`pwd`/llvm-x86_64-unknown-linux-gnu.tar.xz" >> $GITHUB_ENV
31+
echo "PORTABLE_CC_TOOLCHAIN_SYSROOT=`pwd`/sysroot-x86_64-unknown-linux-gnu.tar.xz" >> $GITHUB_ENV
32+
33+
- name: Build
34+
working-directory: cmake/version
35+
run: cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=portable_cc_toolchain/toolchain.cmake && cmake --build build
36+
37+
- name: Generate version info
38+
run: cmake/version/build/version | tee version_info.md
39+
40+
- name: Upload version info
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: version-info
44+
path: version_info.md
45+
if-no-files-found: error

cmake/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
test/build
2+
version/build

cmake/version/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
include(FetchContent)
4+
5+
FetchContent_Declare(
6+
PortableCcToolchain
7+
URL "${CMAKE_SOURCE_DIR}/../portable_cc_toolchain"
8+
SOURCE_DIR "${CMAKE_BINARY_DIR}/portable_cc_toolchain"
9+
)
10+
FetchContent_MakeAvailable(PortableCcToolchain)
11+
12+
project(Version)
13+
14+
add_executable(version main.cpp)

cmake/version/main.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include <features.h>
2+
#include <iostream>
3+
#include <linux/version.h>
4+
#include <sstream>
5+
6+
std::string pad(std::string s) {
7+
if (s.length() < 10)
8+
return s + std::string(10 - s.length(), ' ');
9+
return s;
10+
}
11+
12+
std::string format_version(int major, int minor, int patch = -1) {
13+
std::ostringstream os;
14+
os << major << "." << minor;
15+
if (patch != -1)
16+
os << "." << patch;
17+
return pad(os.str());
18+
}
19+
20+
int main() {
21+
std::cout << "| Component | Version |" << std::endl;
22+
std::cout << "| -------------------- | --------- |" << std::endl;
23+
std::cout << "| Clang | "
24+
<< format_version(__clang_major__, __clang_minor__,
25+
__clang_patchlevel__)
26+
<< "|" << std::endl;
27+
std::cout << "| libstdc++ | "
28+
<< format_version(_GLIBCXX_RELEASE, __GNUC_MINOR__,
29+
__GNUC_PATCHLEVEL__)
30+
<< "|" << std::endl;
31+
std::cout << "| glibc | "
32+
<< format_version(__GLIBC__, __GLIBC_MINOR__) << "|" << std::endl;
33+
std::cout << "| Linux kernel headers | "
34+
<< format_version(LINUX_VERSION_CODE >> 16,
35+
(LINUX_VERSION_CODE >> 8) & 0xFF,
36+
LINUX_VERSION_CODE & 0xFF)
37+
<< "|" << std::endl;
38+
}

0 commit comments

Comments
 (0)