Skip to content

Commit 63ff19f

Browse files
committed
Extract Kernel Version from source and update Release Notes
1 parent db3490f commit 63ff19f

File tree

2 files changed

+69
-25
lines changed

2 files changed

+69
-25
lines changed

.github/actions/action.yml

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ runs:
332332
BUILDCONFIG="$KERNEL_PATH/common/build.config.gki"
333333
CONSTANTSCONFIG="$KERNEL_PATH/common/build.config.constants"
334334
CLANG_VERSION=""
335-
if grep -q '^CONFIG_CLANG_VERSION=' "$DEFCONFIG"; then
336-
CLANG_VERSION=$(grep '^CONFIG_CLANG_VERSION=' "$DEFCONFIG" | head -n1 | cut -d'=' -f2 | tr -d '"')
337-
elif grep -q '^CLANG_VERSION=' "$BUILDCONFIG"; then
338-
CLANG_VERSION=$(grep '^CLANG_VERSION=' "$BUILDCONFIG" | head -n1 | cut -d'=' -f2)
339-
elif grep -q '^CLANG_VERSION=' "$CONSTANTSCONFIG"; then
340-
CLANG_VERSION=$(grep '^CLANG_VERSION=' "$CONSTANTSCONFIG" | head -n1 | cut -d'=' -f2)
335+
if grep -q '^CONFIG_CLANG_VERSION=' "$DEFCONFIG" 2>/dev/null; then
336+
CLANG_VERSION=$(grep '^CONFIG_CLANG_VERSION=' "$DEFCONFIG" 2>/dev/null | head -n1 | cut -d'=' -f2 | tr -d '"' | xargs)
337+
elif grep -q '^CLANG_VERSION=' "$BUILDCONFIG" 2>/dev/null; then
338+
CLANG_VERSION=$(grep '^CLANG_VERSION=' "$BUILDCONFIG" 2>/dev/null | head -n1 | cut -d'=' -f2 | xargs)
339+
elif grep -q '^CLANG_VERSION=' "$CONSTANTSCONFIG" 2>/dev/null; then
340+
CLANG_VERSION=$(grep '^CLANG_VERSION=' "$CONSTANTSCONFIG" 2>/dev/null | head -n1 | cut -d'=' -f2 | xargs)
341341
CLANG_VERSION="clang-$CLANG_VERSION"
342342
else
343343
echo "No clang version found in config, will auto-detect in prebuilts."
@@ -405,6 +405,7 @@ runs:
405405
make -j$(nproc --all) O=out $MAKE_ARGS || exit 1
406406
407407
- name: Create Kernel ZIP
408+
id: create_zip
408409
shell: bash
409410
run: |
410411
CONFIG_DIR="$GITHUB_WORKSPACE/${{ env.CONFIG }}"
@@ -421,8 +422,65 @@ runs:
421422
echo "Creating zip file $ZIP_NAME in $ARTIFACTS_DIR..."
422423
zip -r "$ARTIFACTS_DIR/$ZIP_NAME" ./*
423424
425+
- name: Save Build Metadata
426+
shell: bash
427+
if: success() && steps.create_zip.conclusion == 'success'
428+
id: save_metadata
429+
run: |
430+
CONFIG_DIR="$GITHUB_WORKSPACE/${{ env.CONFIG }}"
431+
ARTIFACTS_DIR="$CONFIG_DIR/artifacts"
432+
cd "$ARTIFACTS_DIR"
433+
if [ -z "$(ls *.zip 2>/dev/null)" ]; then
434+
echo "No kernel zip found! Artifact upload might be fake."
435+
exit 1
436+
fi
437+
438+
cd "$CONFIG_DIR/kernel_platform/common"
439+
CONFIG_FILES=("build.config.common" "build.config.constants")
440+
BRANCH_LINE=""
441+
442+
for file in "${CONFIG_FILES[@]}"; do
443+
if [ -f "$file" ]; then
444+
line=$(grep '^[[:space:]]*BRANCH=' "$file" | head -n1 || true)
445+
if [ -n "$line" ]; then
446+
BRANCH_LINE="$line"
447+
echo "Found BRANCH in: $file"
448+
break # Found it — exit loop
449+
else
450+
echo "File exists but no BRANCH= found: $file"
451+
fi
452+
else
453+
echo "File not found: $file"
454+
fi
455+
done
456+
457+
if [ -z "$BRANCH_LINE" ]; then
458+
echo "Error: No BRANCH= found in any of: ${CONFIG_FILES[*]}"
459+
exit 1
460+
fi
461+
462+
BRANCH_VALUE="${BRANCH_LINE#*=}"
463+
ANDROID_VERSION="${BRANCH_VALUE%-*}"
464+
465+
if [ -z "$ANDROID_VERSION" ]; then
466+
echo "Error: Could not extract 'androidXX' from BRANCH='$BRANCH_VALUE'"
467+
exit 1
468+
fi
469+
470+
# Extract values using grep and awk
471+
VERSION=$(grep '^VERSION *=' Makefile | awk '{print $3}')
472+
PATCHLEVEL=$(grep '^PATCHLEVEL *=' Makefile | awk '{print $3}')
473+
SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | awk '{print $3}')
474+
FULL_VERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
475+
476+
echo "Kernel Version: $ANDROID_VERSION-$FULL_VERSION"
477+
478+
cd "$ARTIFACTS_DIR"
479+
echo "$ANDROID_VERSION-$FULL_VERSION" > ${{ inputs.model }}.txt
480+
424481
- name: Upload Artifacts
425482
uses: actions/upload-artifact@v4
426483
with:
427484
name: kernel-${{ env.CONFIG }}
428-
path: ${{ env.CONFIG }}/artifacts/*.zip
485+
path: |
486+
${{ env.CONFIG }}/artifacts/*

.github/workflows/build-kernel-release.yml

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ jobs:
154154
kernel_version: ${{ matrix.kernel_version }}
155155
ksun_branch: ${{ inputs.ksun_branch }}
156156
susfs_branch: ${{ steps.get-susfs-branch.outputs.susfs_branch }}
157-
158-
- name: Upload Build Artifacts
159-
uses: actions/upload-artifact@v4
160-
with:
161-
name: ${{ matrix.model }}-kernel
162-
path: ${{ matrix.model }}/artifacts/
163-
if-no-files-found: error
164157

165158
build-batch-2:
166159
name: build-batch-2 (${{ matrix.model }}, ${{ matrix.soc }}, ${{ matrix.branch }}, ${{ matrix.manifest }}, ${{ matrix.android_version }}, ${{ matrix.kernel_version }}, ${{ inputs.ksun_branch }})
@@ -282,13 +275,6 @@ jobs:
282275
kernel_version: ${{ matrix.kernel_version }}
283276
ksun_branch: ${{ inputs.ksun_branch }}
284277
susfs_branch: ${{ steps.get-susfs-branch.outputs.susfs_branch }}
285-
286-
- name: Upload Build Artifacts
287-
uses: actions/upload-artifact@v4
288-
with:
289-
name: ${{ matrix.model }}-kernel
290-
path: ${{ matrix.model }}/artifacts/
291-
if-no-files-found: error
292278

293279
trigger-release:
294280
needs:
@@ -348,11 +334,11 @@ jobs:
348334
EOF
349335
350336
# Generate table rows
351-
for file in $(find downloaded-artifacts -name "*.zip" -type f | sort); do
337+
for file in $(find downloaded-artifacts -name "*.txt" -type f | sort); do
352338
if [ -f "$file" ]; then
353-
model=$(basename "$(dirname "$file")" | sed 's/-kernel$//')
354-
kernel_version=$(grep -oP 'android\d+-\d+\.\d+' "$file" || echo "${{ matrix.android_version }}-${{ matrix.kernel_version }}")
355-
printf "| %-12s | %-16s |\n" "$model" "$kernel_version" >> release_notes.md
339+
model=$(basename "$file" .txt)
340+
version=$(cat "$file")
341+
printf "| %-12s | %-16s |\n" "$model" "$version" >> release_notes.md
356342
fi
357343
done
358344

0 commit comments

Comments
 (0)