@@ -286,6 +286,62 @@ runs:
286286 echo "CONFIG_IP6_NF_TARGET_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
287287 echo "CONFIG_IP6_NF_MATCH_HL=y" >> ./common/arch/arm64/configs/gki_defconfig
288288
289+ - name : Save Build Metadata
290+ shell : bash
291+ id : save_metadata
292+ run : |
293+ CONFIG_DIR="$GITHUB_WORKSPACE/${{ env.CONFIG }}"
294+ ARTIFACTS_DIR="$CONFIG_DIR/artifacts"
295+ cd "$ARTIFACTS_DIR"
296+ if [ -z "$(ls *.zip 2>/dev/null)" ]; then
297+ echo "No kernel zip found! Artifact upload might be fake."
298+ exit 1
299+ fi
300+
301+ cd "$CONFIG_DIR/kernel_platform/common"
302+ CONFIG_FILES=("build.config.common" "build.config.constants")
303+ BRANCH_LINE=""
304+
305+ for file in "${CONFIG_FILES[@]}"; do
306+ if [ -f "$file" ]; then
307+ line=$(grep '^[[:space:]]*BRANCH=' "$file" | head -n1 || true)
308+ if [ -n "$line" ]; then
309+ BRANCH_LINE="$line"
310+ echo "Found BRANCH in: $file"
311+ break # Found it — exit loop
312+ else
313+ echo "File exists but no BRANCH= found: $file"
314+ fi
315+ else
316+ echo "File not found: $file"
317+ fi
318+ done
319+
320+ if [ -z "$BRANCH_LINE" ]; then
321+ echo "Error: No BRANCH= found in any of: ${CONFIG_FILES[*]}"
322+ exit 1
323+ fi
324+
325+ BRANCH_VALUE="${BRANCH_LINE#*=}"
326+ ANDROID_VERSION="${BRANCH_VALUE%-*}"
327+
328+ if [ -z "$ANDROID_VERSION" ]; then
329+ echo "Error: Could not extract 'androidXX' from BRANCH='$BRANCH_VALUE'"
330+ exit 1
331+ fi
332+
333+ # Extract values using grep and awk
334+ VERSION=$(grep '^VERSION *=' Makefile | awk '{print $3}')
335+ PATCHLEVEL=$(grep '^PATCHLEVEL *=' Makefile | awk '{print $3}')
336+ SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | awk '{print $3}')
337+ FULL_VERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
338+
339+ echo "Kernel Version: $ANDROID_VERSION-$FULL_VERSION"
340+
341+ cd "$ARTIFACTS_DIR"
342+ echo "$ANDROID_VERSION-$FULL_VERSION" > ${{ inputs.model }}.txt
343+ echo "KERNEL_VER=$ANDROID_VERSION-$FULL_VERSION" >> $GITHUB_ENV
344+
289345 - name : Run sed and perl Commands
290346 shell : bash
291347 run : |
@@ -296,12 +352,12 @@ runs:
296352 sed -i 's/CONFIG_LTO_CLANG_FULL=y/CONFIG_LTO_CLANG_THIN=y/' "./common/arch/arm64/configs/gki_defconfig"
297353 sed -i 's/CONFIG_LTO_CLANG_NONE=y/CONFIG_LTO_CLANG_THIN=y/' "./common/arch/arm64/configs/gki_defconfig"
298354 sed -i 's/check_defconfig//' ./common/build.config.gki
299- tac ./common/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\) -OP-Wild\;echo "\$res"\;/' | tac > ./common/scripts/setlocalversion.tmp && mv ./common/scripts/setlocalversion.tmp ./common/scripts/setlocalversion
300- tac ./msm-kernel/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\) -OP-Wild\;echo "\$res"\;/' | tac > ./msm-kernel/scripts/setlocalversion.tmp && mv ./msm-kernel/scripts/setlocalversion.tmp ./msm-kernel/scripts/setlocalversion
301- tac ./external/dtc/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$\(echo \$res \| cut -d- -f1-2\) -OP-Wild\;echo "\$res"\;/' | tac > ./external/dtc/scripts/setlocalversion.tmp && mv ./external/dtc/scripts/setlocalversion.tmp ./external/dtc/scripts/setlocalversion
302- sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./common/scripts/setlocalversion
303- sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./msm-kernel/scripts/setlocalversion
304- sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${KERNELVERSION}-${{ inputs.android_version }}-OP-Wild"/' ./external/dtc/scripts/setlocalversion
355+ tac ./common/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$${{ env.KERNEL_VER }} -OP-Wild\;echo "\$res"\;/' | tac > ./common/scripts/setlocalversion.tmp && mv ./common/scripts/setlocalversion.tmp ./common/scripts/setlocalversion
356+ tac ./msm-kernel/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$${{ env.KERNEL_VER }} -OP-Wild\;echo "\$res"\;/' | tac > ./msm-kernel/scripts/setlocalversion.tmp && mv ./msm-kernel/scripts/setlocalversion.tmp ./msm-kernel/scripts/setlocalversion
357+ tac ./external/dtc/scripts/setlocalversion | sed '0,/echo "\$res"/s//res=\$${{ env.KERNEL_VER }} -OP-Wild\;echo "\$res"\;/' | tac > ./external/dtc/scripts/setlocalversion.tmp && mv ./external/dtc/scripts/setlocalversion.tmp ./external/dtc/scripts/setlocalversion
358+ sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${{ env.KERNEL_VER }}-OP-Wild"/' ./common/scripts/setlocalversion
359+ sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${{ env.KERNEL_VER }}-OP-Wild"/' ./msm-kernel/scripts/setlocalversion
360+ sed -i 's/echo "${KERNELVERSION}${file_localversion}${config_localversion}${LOCALVERSION}${scm_version}"/echo "${{ env.KERNEL_VER }}-OP-Wild"/' ./external/dtc/scripts/setlocalversion
305361 chmod +x ./common/scripts/setlocalversion
306362 chmod +x ./msm-kernel/scripts/setlocalversion
307363 chmod +x ./external/dtc/scripts/setlocalversion
@@ -434,63 +490,8 @@ runs:
434490 echo "Creating zip file $ZIP_NAME in $ARTIFACTS_DIR..."
435491 zip -r "$ARTIFACTS_DIR/$ZIP_NAME" ./*
436492
437- - name : Save Build Metadata
438- shell : bash
439- if : success() && steps.create_zip.conclusion == 'success'
440- id : save_metadata
441- run : |
442- CONFIG_DIR="$GITHUB_WORKSPACE/${{ env.CONFIG }}"
443- ARTIFACTS_DIR="$CONFIG_DIR/artifacts"
444- cd "$ARTIFACTS_DIR"
445- if [ -z "$(ls *.zip 2>/dev/null)" ]; then
446- echo "No kernel zip found! Artifact upload might be fake."
447- exit 1
448- fi
449-
450- cd "$CONFIG_DIR/kernel_platform/common"
451- CONFIG_FILES=("build.config.common" "build.config.constants")
452- BRANCH_LINE=""
453-
454- for file in "${CONFIG_FILES[@]}"; do
455- if [ -f "$file" ]; then
456- line=$(grep '^[[:space:]]*BRANCH=' "$file" | head -n1 || true)
457- if [ -n "$line" ]; then
458- BRANCH_LINE="$line"
459- echo "Found BRANCH in: $file"
460- break # Found it — exit loop
461- else
462- echo "File exists but no BRANCH= found: $file"
463- fi
464- else
465- echo "File not found: $file"
466- fi
467- done
468-
469- if [ -z "$BRANCH_LINE" ]; then
470- echo "Error: No BRANCH= found in any of: ${CONFIG_FILES[*]}"
471- exit 1
472- fi
473-
474- BRANCH_VALUE="${BRANCH_LINE#*=}"
475- ANDROID_VERSION="${BRANCH_VALUE%-*}"
476-
477- if [ -z "$ANDROID_VERSION" ]; then
478- echo "Error: Could not extract 'androidXX' from BRANCH='$BRANCH_VALUE'"
479- exit 1
480- fi
481-
482- # Extract values using grep and awk
483- VERSION=$(grep '^VERSION *=' Makefile | awk '{print $3}')
484- PATCHLEVEL=$(grep '^PATCHLEVEL *=' Makefile | awk '{print $3}')
485- SUBLEVEL=$(grep '^SUBLEVEL *=' Makefile | awk '{print $3}')
486- FULL_VERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
487-
488- echo "Kernel Version: $ANDROID_VERSION-$FULL_VERSION"
489-
490- cd "$ARTIFACTS_DIR"
491- echo "$ANDROID_VERSION-$FULL_VERSION" > ${{ inputs.model }}.txt
492-
493493 - name : Upload Artifacts
494+ if : success() && steps.create_zip.conclusion == 'success'
494495 uses : actions/upload-artifact@v4
495496 with :
496497 name : kernel-${{ env.CONFIG }}
0 commit comments