Bladeren bron

ci: refactor GitHub Actions into reusable composite actions

- Extract inline shell scripts into dedicated composite actions for clarity and maintainability
- Add new actions: parse-kernel-version, setup-build-environment, extract-sublevel-file-name, kernel-fixes, module-check-bypass, misc, remove-protected-exports, build-kernel, prepare-anykernel3, scan-patch-rejects, build-boot-images
- Remove deprecated actions: bbr, telegram-notify
- Update artifact upload/download actions from v5 to v7
- Simplify main workflow by referencing composite actions
TheWildJames 4 maanden geleden
bovenliggende
commit
dfd4fb52d9

+ 1 - 8
.github/actions/apply-kernel-branding/action.yml

@@ -1,12 +1,5 @@
-name: 'Apply Kernel Branding'
+name: 'Apply Kernel Branding & Timestamp'
 description: 'Apply Wild kernel branding to kernel version string'
-inputs:
-  build_type:
-    description: 'Build type (Normal, Bypass, MarionKernel, Hakan, etc.)'
-    required: true
-  kernel_version:
-    description: 'Kernel version (e.g., 5.10, 6.1, 6.6)'
-    required: true
 
 runs:
   using: "composite"

+ 0 - 52
.github/actions/bbr/action.yml

@@ -1,52 +0,0 @@
-name: Setup TCP BBR v3
-description: configure TCP BBR v3
-inputs:
-  kernel_version:
-    description: 'Kernel version (e.g., 6.6)'
-    required: true
-  android_version:
-    description: 'Android version (e.g., 12)'
-    required: true
-
-runs:
-  using: composite
-  steps:
-    - name: Extract BBG Version
-      shell: bash
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        cp "$GITHUB_WORKSPACE/kernel_patches/bbr/bbrv3-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch" "$GITHUB_WORKSPACE/kernel/common"
-        patch -p1 < "bbrv3-${{ inputs.android_version }}-${{ inputs.kernel_version }}.patch"
-
-    - name: Fix modules.bzl
-      shell: bash
-      if: false
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        if [ "${{ inputs.kernel_version }}" = "6.1" ]; then
-          mods_file=modules.bzl
-          for m in "net/ipv4/tcp_bic.ko" "net/ipv4/tcp_htcp.ko" "net/ipv4/tcp_westwood.ko"; do
-            grep -q "'$m'" "$mods_file" && continue
-            sed -i "/_ARM64_GKI_MODULES_LIST = \[/,/^]/ s/^]/    \"$m\",\n]/" "$mods_file"
-          done
-        fi
-
-    - name: Add BBRv3 Config
-      shell: bash
-      working-directory: ${{ github.workspace }}/kernel
-      run: |
-        cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
-        CONFIG_TCP_CONG_ADVANCED=y
-        CONFIG_TCP_CONG_BBR=y
-        CONFIG_TCP_CONG_CUBIC=y
-        CONFIG_TCP_CONG_BIC=y
-        CONFIG_TCP_CONG_WESTWOOD=y
-        CONFIG_TCP_CONG_HTCP=y
-        CONFIG_DEFAULT_BBR=y
-        CONFIG_DEFAULT_TCP_CONG="bbr"
-        CONFIG_NET_SCH_FQ=y
-
-        EOF
-        
-
-    

+ 71 - 0
.github/actions/build-boot-images/action.yml

@@ -0,0 +1,71 @@
+name: 'Build Boot Images'
+description: 'Creates boot artifacts (boot.img, boot-gz.img, boot-lz4.img) and stores them in boot-artifacts/'
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      working-directory: ${{ github.workspace }}
+      run: |
+        set -euo pipefail
+
+        mkdir -p bootimgs
+        mkdir -p boot-artifacts
+
+        if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
+          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
+          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
+        else
+          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
+          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
+        fi
+
+        gzip -n -k -f -9 "$GITHUB_WORKSPACE/bootimgs/Image" > "$GITHUB_WORKSPACE/bootimgs/Image.gz"
+
+        cd "$GITHUB_WORKSPACE/bootimgs"
+
+        case "$ANDROID_VERSION" in
+          android12)
+            GKI_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-${OS_PATCH_LEVEL}_r1.zip"
+            FALLBACK_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip"
+
+            status="$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null || true)"
+            if [ "$status" = "200" ]; then
+              curl -L -o gki-kernel.zip "$GKI_URL"
+            else
+              curl -L -o gki-kernel.zip "$FALLBACK_URL"
+            fi
+
+            unzip -q gki-kernel.zip
+            rm -f gki-kernel.zip
+
+            if [ -f "./boot-5.10.img" ]; then
+              BOOT_IMG="./boot-5.10.img"
+            else
+              BOOT_IMG="$(ls -1 ./boot-*.img 2>/dev/null | head -n 1 || true)"
+            fi
+
+            if [ -z "${BOOT_IMG:-}" ]; then
+              exit 1
+            fi
+
+            "$UNPACK_BOOTIMG" --boot_img="$PWD/$BOOT_IMG"
+            ;;
+        esac
+
+        for kernel_image in Image Image.gz Image.lz4; do
+          case "$kernel_image" in
+            Image) output_image="boot.img" ;;
+            Image.gz) output_image="boot-gz.img" ;;
+            Image.lz4) output_image="boot-lz4.img" ;;
+          esac
+
+          if [ "$ANDROID_VERSION" = "android12" ]; then
+            "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image" --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "$OS_PATCH_LEVEL"
+          else
+            "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image"
+          fi
+
+          "$AVBTOOL" add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image "$output_image" --algorithm SHA256_RSA2048 --key "$BOOT_SIGN_KEY_PATH"
+          cp "$output_image" "$GITHUB_WORKSPACE/boot-artifacts/${FILE_NAME}-${output_image}"
+        done

+ 18 - 0
.github/actions/build-kernel/action.yml

@@ -0,0 +1,18 @@
+name: 'Build Kernel'
+description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      working-directory: ${{ github.workspace }}/kernel
+      run: |
+        set -euo pipefail
+
+        if [ -f "build/build.sh" ]; then
+          GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh
+          exit 0
+        fi
+
+        cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
+        tools/bazel build --config=release --stamp --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist

+ 33 - 0
.github/actions/extract-sublevel-file-name/action.yml

@@ -0,0 +1,33 @@
+name: 'Extract Sublevel and File Name'
+description: 'Reads Makefile sublevel and composes FILE_NAME'
+inputs:
+  variant:
+    required: true
+    type: string
+outputs:
+  file_name:
+    value: ${{ steps.extract.outputs.file_name }}
+  sublevel:
+    value: ${{ steps.extract.outputs.sublevel }}
+
+runs:
+  using: composite
+  steps:
+    - id: extract
+      shell: bash
+      run: |
+        set -euo pipefail
+
+        SUBLEVEL="${SUB_LEVEL}"
+        if [ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]; then
+          EXTRACTED="$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}')"
+          if [ -n "$EXTRACTED" ]; then SUBLEVEL="$EXTRACTED"; fi
+        fi
+
+        FILE_NAME="${KERNEL_VERSION}.${SUBLEVEL}-${ANDROID_VERSION}-${OS_PATCH_LEVEL}-${{ inputs.variant }}"
+
+        echo "SUBLEVEL=$SUBLEVEL" >> "$GITHUB_ENV"
+        echo "FILE_NAME=$FILE_NAME" >> "$GITHUB_ENV"
+
+        echo "file_name=$FILE_NAME" >> "$GITHUB_OUTPUT"
+        echo "sublevel=$SUBLEVEL" >> "$GITHUB_OUTPUT"

+ 53 - 0
.github/actions/kernel-fixes/action.yml

@@ -0,0 +1,53 @@
+name: 'Kernel Fixes'
+description: 'Applies compatibility fixes based on android/kernel/sublevel'
+inputs:
+  android_version:
+    required: true
+    type: string
+  kernel_version:
+    required: true
+    type: string
+  sublevel:
+    required: true
+    type: string
+  os_patch_level:
+    required: true
+    type: string
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      run: |
+        set -euo pipefail
+
+        ANDROID_VERSION="${{ inputs.android_version }}"
+        KERNEL_VERSION="${{ inputs.kernel_version }}"
+        SUBLEVEL="${{ inputs.sublevel }}"
+        OS_PATCH_LEVEL="${{ inputs.os_patch_level }}"
+
+        if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \
+             [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \
+             [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]] || \
+             [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && "$SUBLEVEL" -le 43 ]]; }; then
+          GLIBC_VERSION="$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}')"
+          if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n 1)" = "2.38" ]; then
+            cd "$GITHUB_WORKSPACE/kernel/common"
+            sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true
+            if { [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && "$SUBLEVEL" -le 186 ]] || \
+                 [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 119 ]] || \
+                 [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && "$SUBLEVEL" -le 110 ]]; }; then
+              sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
+              sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
+              sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
+              sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
+            fi
+          fi
+        fi
+
+        if [ "$ANDROID_VERSION" = "android15" ] && [ "$KERNEL_VERSION" = "6.6" ]; then
+          cd "$GITHUB_WORKSPACE/kernel/common"
+          if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
+            sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
+          fi
+        fi

+ 29 - 0
.github/actions/misc/action.yml

@@ -0,0 +1,29 @@
+name: 'Setup Misc Configs'
+description: 'Set up kernel configuration fragment with miscellaneous options'
+inputs:
+  kernel_version:
+    description: 'Kernel version (e.g., 6.1)'
+    required: true
+  android_version:
+    description: 'Android version (e.g., android14)'
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Apply Kernel Configuration
+      shell: bash
+      run: |
+        cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
+        # Mountify Support
+        CONFIG_OVERLAY_FS=y
+        CONFIG_TMPFS_XATTR=y
+        CONFIG_TMPFS_POSIX_ACL=y
+
+        # KPatch-Next Support
+        CONFIG_KALLSYMS=y
+        CONFIG_KALLSYMS_ALL=y
+
+        # Improve General Compatibility
+        # CONFIG_TRIM_UNUSED_KSYMS is not set
+        EOF

+ 29 - 0
.github/actions/module-check-bypass/action.yml

@@ -0,0 +1,29 @@
+name: 'Module Check Bypass'
+description: 'Applies module version check bypass and verifies it'
+inputs:
+  kernel_version:
+    required: true
+    type: string
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      run: |
+        set -euo pipefail
+
+        KERNEL_VERSION="${{ inputs.kernel_version }}"
+        if [[ "$KERNEL_VERSION" == "6.1" || "$KERNEL_VERSION" == "6.6" || "$KERNEL_VERSION" == "6.12" ]]; then
+          TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module/version.c"
+        else
+          TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module.c"
+        fi
+
+        sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
+
+        if grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
+          exit 0
+        fi
+
+        grep -A 5 "bad_version:" "$TARGET_FILE" || true
+        exit 1

+ 40 - 0
.github/actions/parse-kernel-version/action.yml

@@ -0,0 +1,40 @@
+name: 'Parse Kernel Version'
+description: 'Parses input kernel_version into kernel/android/patch parts and exports them'
+inputs:
+  kernel_version:
+    required: true
+    type: string
+outputs:
+  android_version:
+    value: ${{ steps.parse.outputs.android_version }}
+  kernel_version:
+    value: ${{ steps.parse.outputs.kernel_version }}
+  sub_level:
+    value: ${{ steps.parse.outputs.sub_level }}
+  os_patch_level:
+    value: ${{ steps.parse.outputs.os_patch_level }}
+
+runs:
+  using: composite
+  steps:
+    - id: parse
+      shell: bash
+      run: |
+        set -euo pipefail
+
+        INPUT_VERSION="${{ inputs.kernel_version }}"
+        IFS='-' read -r KERNEL_PART ANDROID_PART REST <<< "$INPUT_VERSION"
+        KERNEL_VERSION="${KERNEL_PART%.*}"
+        SUB_LEVEL="${KERNEL_PART##*.}"
+        ANDROID_VERSION="$ANDROID_PART"
+        OS_PATCH_LEVEL="$REST"
+
+        echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
+        echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"
+        echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV"
+        echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV"
+
+        echo "android_version=$ANDROID_VERSION" >> "$GITHUB_OUTPUT"
+        echo "kernel_version=$KERNEL_VERSION" >> "$GITHUB_OUTPUT"
+        echo "sub_level=$SUB_LEVEL" >> "$GITHUB_OUTPUT"
+        echo "os_patch_level=$OS_PATCH_LEVEL" >> "$GITHUB_OUTPUT"

+ 21 - 0
.github/actions/prepare-anykernel3/action.yml

@@ -0,0 +1,21 @@
+name: 'Prepare AnyKernel3'
+description: 'Copies built Image into AnyKernel3 folder'
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      run: |
+        set -euo pipefail
+
+        if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
+          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
+          exit 0
+        fi
+
+        if [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
+          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
+          exit 0
+        fi
+
+        exit 1

+ 48 - 0
.github/actions/remove-protected-exports/action.yml

@@ -0,0 +1,48 @@
+name: 'Remove Protected Exports'
+description: 'Remove ABI protected exports and protected modules for Bazel builds with verification'
+
+runs:
+  using: "composite"
+  steps:
+    - name: Remove Protected Exports (Bazel)
+      shell: bash
+      working-directory: ${{ github.workspace }}/kernel
+      run: |
+        set -euo pipefail
+
+        if [ -f "build/build.sh" ]; then
+          exit 0
+        fi
+
+        rm -rf common/android/abi_gki_protected_exports_*
+
+        if ls -1 common/android/abi_gki_protected_exports_* >/dev/null 2>&1; then
+          echo "Error: abi_gki_protected_exports_* still exists after removal"
+          ls -la common/android/abi_gki_protected_exports_* || true
+          exit 1
+        fi
+
+        BEFORE_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
+        perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' common/BUILD.bazel
+        AFTER_BUILD_BAZEL_SHA="$(sha256sum common/BUILD.bazel | awk '{print $1}')"
+        if [ "$BEFORE_BUILD_BAZEL_SHA" = "$AFTER_BUILD_BAZEL_SHA" ]; then
+          echo "Error: common/BUILD.bazel was not modified"
+          exit 1
+        fi
+        if grep -q '"protected_exports_list"[[:space:]]*:[[:space:]]*"android/abi_gki_protected_exports_aarch64"' common/BUILD.bazel; then
+          echo "Error: protected_exports_list reference still present in common/BUILD.bazel"
+          exit 1
+        fi
+
+        BEFORE_MODULES_BZL_SHA="$(sha256sum common/modules.bzl | awk '{print $1}')"
+        sed -i 's/protected_modules = \[.*\]/protected_modules = []/' common/modules.bzl
+        AFTER_MODULES_BZL_SHA="$(sha256sum common/modules.bzl | awk '{print $1}')"
+        if [ "$BEFORE_MODULES_BZL_SHA" = "$AFTER_MODULES_BZL_SHA" ]; then
+          echo "Error: common/modules.bzl was not modified"
+          exit 1
+        fi
+        if ! grep -q '^protected_modules = \[\]' common/modules.bzl; then
+          echo "Error: protected_modules was not set to [] in common/modules.bzl"
+          exit 1
+        fi
+

+ 37 - 0
.github/actions/scan-patch-rejects/action.yml

@@ -0,0 +1,37 @@
+name: 'Scan Patch Rejects'
+description: 'Collects .rej files into patch-rejects directory and outputs count'
+outputs:
+  rej_count:
+    value: ${{ steps.scan.outputs.rej_count }}
+
+runs:
+  using: composite
+  steps:
+    - id: scan
+      shell: bash
+      run: |
+        set -euo pipefail
+
+        CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
+        REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
+        mkdir -p "$REJECTS_DIR"
+        mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
+        REJ_COUNT=${#REJS[@]}
+        echo "REJ_COUNT=$REJ_COUNT" >> "$GITHUB_ENV"
+        echo "rej_count=$REJ_COUNT" >> "$GITHUB_OUTPUT"
+
+        if [ "$REJ_COUNT" -gt 0 ]; then
+          for REJ in "${REJS[@]}"; do
+            REL="${REJ#"$CONFIG_DIR"/}"
+            DEST="$REJECTS_DIR/$REL"
+            mkdir -p "$(dirname "$DEST")"
+            cp "$REJ" "$DEST"
+            ORIG="${REJ%.rej}"
+            if [ -f "$ORIG" ]; then
+              ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
+              mkdir -p "$(dirname "$ORIG_DEST")"
+              cp "$ORIG" "$ORIG_DEST"
+            fi
+            echo "$REL" >> "$REJECTS_DIR/index.txt"
+          done
+        fi

+ 64 - 0
.github/actions/setup-build-environment/action.yml

@@ -0,0 +1,64 @@
+name: 'Setup Build Environment'
+description: 'Clones dependencies and exports mkbootimg/avbtool paths'
+inputs:
+  patches_commit:
+    required: false
+    type: string
+  anykernel_commit:
+    required: false
+    type: string
+
+runs:
+  using: composite
+  steps:
+    - shell: bash
+      run: |
+        set -euo pipefail
+
+        mkdir -p "$GITHUB_WORKSPACE/kernel"
+        mkdir -p "$GITHUB_WORKSPACE/git-repo"
+        curl -L https://storage.googleapis.com/git-repo-downloads/repo -o "$GITHUB_WORKSPACE/git-repo/repo"
+        chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
+        echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
+
+        if [ -n "${{ inputs.patches_commit }}" ]; then
+          if [ -d "$GITHUB_WORKSPACE/kernel_patches" ]; then rm -rf "$GITHUB_WORKSPACE/kernel_patches"; fi
+          git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
+          cd "$GITHUB_WORKSPACE/kernel_patches"
+          git checkout "${{ inputs.patches_commit }}"
+          cd "$GITHUB_WORKSPACE"
+        else
+          git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
+        fi
+
+        if [ -n "${{ inputs.anykernel_commit }}" ]; then
+          if [ -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then rm -rf "$GITHUB_WORKSPACE/AnyKernel3"; fi
+          git clone https://github.com/WildKernels/AnyKernel3.git "$GITHUB_WORKSPACE/AnyKernel3"
+          cd "$GITHUB_WORKSPACE/AnyKernel3"
+          git checkout "${{ inputs.anykernel_commit }}"
+          cd "$GITHUB_WORKSPACE"
+        elif [ ! -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then
+          git clone https://github.com/WildKernels/AnyKernel3.git -b gki-2.0 "$GITHUB_WORKSPACE/AnyKernel3"
+        fi
+
+        AOSP_MIRROR=https://android.googlesource.com
+        BRANCH=main-kernel-2025
+        git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
+        git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
+
+        echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> "$GITHUB_ENV"
+        echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> "$GITHUB_ENV"
+        echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> "$GITHUB_ENV"
+        echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> "$GITHUB_ENV"
+
+        mkdir -p "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb"
+        if [ -z "${BOOT_SIGN_KEY:-}" ]; then
+          exit 1
+        fi
+
+        KEY_PATH="$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem"
+        printf '%s' "$BOOT_SIGN_KEY" > "$KEY_PATH"
+        if ! head -n 1 "$KEY_PATH" | grep -q 'BEGIN'; then
+          printf '%s' "$BOOT_SIGN_KEY" | base64 -d > "$KEY_PATH"
+        fi
+        chmod 600 "$KEY_PATH"

+ 0 - 112
.github/actions/telegram-notify/action.yml

@@ -1,112 +0,0 @@
-name: 'Telegram Notification'
-description: 'Send Telegram notifications for kernel builds'
-inputs:
-  release_type:
-    description: 'Type of release (Actions, Pre-Release, Release)'
-    required: true
-  new_tag:
-    description: 'New release tag'
-    required: false
-    default: ''
-  release_result:
-    description: 'Result of the release job'
-    required: false
-    default: 'success'
-  telegram_bot_token:
-    description: 'Telegram bot token'
-    required: true
-  telegram_chat_id:
-    description: 'Telegram chat ID for announcements'
-    required: true
-  telegram_topic_id:
-    description: 'Telegram topic/thread ID'
-    required: true
-  telegram_user_id:
-    description: 'Telegram user ID for direct messages'
-    required: true
-  artifact_pattern:
-    description: 'Pattern for artifacts to download'
-    required: false
-    default: '*-TheWildJames-AnyKernel3'
-
-runs:
-  using: "composite"
-  steps:
-    - name: Download Kernel Artifacts
-      uses: actions/download-artifact@v5
-      with:
-        path: ./downloaded-artifacts
-        pattern: ${{ inputs.artifact_pattern }}
-        
-    - name: Prepare Artifact Zips
-      shell: bash
-      run: |
-        shopt -s nullglob
-        # Iterate over directories in downloaded-artifacts
-        for dir in ./downloaded-artifacts/*-AnyKernel3; do
-          [ -d "$dir" ] || continue
-          artifact_name=$(basename "$dir")
-          # Create zip for each artifact
-          (cd "$dir" && zip -r -q -9 "$GITHUB_WORKSPACE/${artifact_name}.zip" ./*)
-        done
-
-    - name: Send Telegram Notification (Actions)
-      if: ${{ inputs.release_type == 'Actions' }}
-      shell: bash
-      run: |
-        curl -X POST "https://api.telegram.org/bot${{ inputs.telegram_bot_token }}/sendMessage" \
-          -F chat_id="${{ inputs.telegram_chat_id }}" \
-          -F message_thread_id="${{ inputs.telegram_topic_id }}" \
-          -F text="
-          🌽 *New Kernel Actions Build Finished*
-          📦 *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})
-          ✏️ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
-          [🔗 View Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})" \
-          -F parse_mode="Markdown"
-
-    - name: Send Telegram Notification (Release)
-      if: ${{ inputs.release_type != 'Actions' && inputs.release_result == 'success' }}
-      shell: bash
-      run: |
-        RELEASE_TYPE_TEXT=""
-        if [ "${{ inputs.release_type }}" == "Pre-Release" ]; then
-          RELEASE_TYPE_TEXT="🧪 *Pre-Release*"
-        else
-          RELEASE_TYPE_TEXT="🚀 *Release*"
-        fi
-
-        curl -X POST "https://api.telegram.org/bot${{ inputs.telegram_bot_token }}/sendMessage" \
-          -F chat_id="${{ inputs.telegram_chat_id }}" \
-          -F message_thread_id="${{ inputs.telegram_topic_id }}" \
-          -F text="
-          🌽 *New Kernel $RELEASE_TYPE_TEXT Uploaded*  
-          📦 *Repository:* [${{ github.repository }}](https://github.com/${{ github.repository }})  
-          ✏️ *Commit:* [${{ github.sha }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})  
-          [🔗 View GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ inputs.new_tag }})" \
-          -F parse_mode="Markdown"
-
-    - name: Send Direct Message with Artifacts
-      if: always()
-      shell: bash
-      run: |
-        shopt -s nullglob
-        files=("$GITHUB_WORKSPACE"/*.zip)
-
-        if [ ${#files[@]} -eq 0 ]; then
-            echo "No ZIP files found for DM."
-            exit 0
-        fi
-
-        if [ -z "${{ inputs.telegram_user_id }}" ]; then
-            echo "Error: telegram_user_id is not set."
-            exit 1
-        fi
-
-        for file in "${files[@]}"; do
-          # Send each zip to Telegram DM
-          # Using || true to prevent failure of one send from failing the whole action
-          curl -v -F chat_id="${{ inputs.telegram_user_id }}" \
-              -F document=@"$file" \
-              -F caption="📦 Build: $(basename "$file")" \
-              https://api.telegram.org/bot${{ inputs.telegram_bot_token }}/sendDocument || true
-        done

+ 52 - 289
.github/workflows/build.yml

@@ -44,40 +44,9 @@ jobs:
 
     - name: Parse kernel version
       id: parse
-      run: |
-        # Parse version string. 
-        # Format: [KERNEL_VERSION].[SUBLEVEL]-[ANDROID_VERSION]-[PATCH_LEVEL]
-        # Example 1: 5.10.198-android12-2024-01 -> K=5.10, S=198, A=android12, P=2024-01
-        # Example 2: 5.10.X-android12-lts       -> K=5.10, S=X,   A=android12, P=lts
-        
-        INPUT_VERSION="${{ inputs.kernel_version }}"
-        
-        # Split by hyphens
-        IFS='-' read -r KERNEL_PART ANDROID_PART REST <<< "$INPUT_VERSION"
-        
-        # Extract Kernel Version and Sublevel
-        KERNEL_VERSION="${KERNEL_PART%.*}"
-        SUB_LEVEL="${KERNEL_PART##*.}"
-        
-        # Extract Android Version
-        ANDROID_VERSION="$ANDROID_PART"
-        
-        # Everything after the android version is the patch level
-        OS_PATCH_LEVEL="$REST"
-  
-        echo "Parsed: KERNEL=$KERNEL_VERSION, SUB=$SUB_LEVEL, ANDROID=$ANDROID_VERSION, PATCH=$OS_PATCH_LEVEL"
-        
-        # Set environment variables for subsequent steps and shell scripts
-        echo "ANDROID_VERSION=$ANDROID_VERSION" >> "$GITHUB_ENV"
-        echo "KERNEL_VERSION=$KERNEL_VERSION" >> "$GITHUB_ENV"
-        echo "SUB_LEVEL=$SUB_LEVEL" >> "$GITHUB_ENV"
-        echo "OS_PATCH_LEVEL=$OS_PATCH_LEVEL" >> "$GITHUB_ENV"
-
-        # Set step outputs for immediate YAML context access (avoids validation warnings)
-        echo "android_version=$ANDROID_VERSION" >> $GITHUB_OUTPUT
-        echo "kernel_version=$KERNEL_VERSION" >> $GITHUB_OUTPUT
-        echo "sub_level=$SUB_LEVEL" >> $GITHUB_OUTPUT
-        echo "os_patch_level=$OS_PATCH_LEVEL" >> $GITHUB_OUTPUT
+      uses: ./.github/actions/parse-kernel-version
+      with:
+        kernel_version: ${{ inputs.kernel_version }}
 
     - name: Free Disk Space
       if: true
@@ -101,51 +70,12 @@ jobs:
         # swap-space-path: /mnt/swapfile   # optional
 
     - name: Setup Build Environment
-      run: |
-        mkdir -p "$GITHUB_WORKSPACE/kernel"
-        mkdir -p "$GITHUB_WORKSPACE/git-repo"
-        curl -L https://storage.googleapis.com/git-repo-downloads/repo -o "$GITHUB_WORKSPACE/git-repo/repo"
-        chmod +x "$GITHUB_WORKSPACE/git-repo/repo"
-        echo "$GITHUB_WORKSPACE/git-repo" >> "$GITHUB_PATH"
-        
-        # Clone patches if commit is provided
-        if [ -n "${{ inputs.patches_commit }}" ]; then
-          echo "Cloning Kernel Patches at commit ${{ inputs.patches_commit }}"
-          if [ -d "$GITHUB_WORKSPACE/kernel_patches" ]; then rm -rf "$GITHUB_WORKSPACE/kernel_patches"; fi
-          git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
-          cd "$GITHUB_WORKSPACE/kernel_patches"
-          git checkout "${{ inputs.patches_commit }}"
-          cd "$GITHUB_WORKSPACE"
-        else
-          git clone https://github.com/WildKernels/kernel_patches.git "$GITHUB_WORKSPACE/kernel_patches"
-        fi
-
-        # Use specific commit if provided
-        if [ -n "${{ inputs.anykernel_commit }}" ]; then
-          echo "Cloning AnyKernel3 at commit ${{ inputs.anykernel_commit }}"
-          if [ -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then rm -rf "$GITHUB_WORKSPACE/AnyKernel3"; fi
-          git clone https://github.com/WildKernels/AnyKernel3.git "$GITHUB_WORKSPACE/AnyKernel3"
-          cd "$GITHUB_WORKSPACE/AnyKernel3"
-          git checkout "${{ inputs.anykernel_commit }}"
-          cd "$GITHUB_WORKSPACE"
-        elif [ ! -d "$GITHUB_WORKSPACE/AnyKernel3" ]; then
-           # Fallback if not downloaded
-           git clone https://github.com/WildKernels/AnyKernel3.git -b gki-2.0 "$GITHUB_WORKSPACE/AnyKernel3"
-        fi
-
-        AOSP_MIRROR=https://android.googlesource.com
-        BRANCH=main-kernel-2025
-        git clone $AOSP_MIRROR/kernel/prebuilts/build-tools -b $BRANCH --depth 1 kernel-build-tools
-        git clone $AOSP_MIRROR/platform/system/tools/mkbootimg -b $BRANCH --depth 1 mkbootimg
-  
-        echo "AVBTOOL=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/bin/avbtool" >> $GITHUB_ENV
-        echo "MKBOOTIMG=$GITHUB_WORKSPACE/mkbootimg/mkbootimg.py" >> $GITHUB_ENV
-        echo "UNPACK_BOOTIMG=$GITHUB_WORKSPACE/mkbootimg/unpack_bootimg.py" >> $GITHUB_ENV
-        echo "BOOT_SIGN_KEY_PATH=$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem" >> $GITHUB_ENV
-
-        mkdir -p "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb"
-        openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem"
-        chmod 600 "$GITHUB_WORKSPACE/kernel-build-tools/linux-x86/share/avb/testkey_rsa2048.pem"
+      uses: ./.github/actions/setup-build-environment
+      env:
+        BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
+      with:
+        patches_commit: ${{ inputs.patches_commit }}
+        anykernel_commit: ${{ inputs.anykernel_commit }}
           
 
     - name: Download Kernel Repository
@@ -157,52 +87,17 @@ jobs:
 
     - name: Extract Sublevel and Set File Name
       id: extract
-      run: |
-        SUBLEVEL="$SUB_LEVEL"
-        if [[ -f "$GITHUB_WORKSPACE/kernel/common/Makefile" ]]; then
-          EXTRACTED=$(grep '^SUBLEVEL = ' "$GITHUB_WORKSPACE/kernel/common/Makefile" | awk '{print $3}')
-          [[ -n "$EXTRACTED" ]] && SUBLEVEL="$EXTRACTED"
-        fi
-
-        VARIANT="${{ matrix.variant }}"
-        FILE_NAME="$KERNEL_VERSION.$SUBLEVEL-$ANDROID_VERSION-$OS_PATCH_LEVEL-$VARIANT"
-        echo "SUBLEVEL=$SUBLEVEL" >> $GITHUB_ENV
-        echo "FILE_NAME=$FILE_NAME" >> $GITHUB_ENV
-        
-        # Set step outputs for parse-time YAML context access
-        echo "file_name=$FILE_NAME" >> $GITHUB_OUTPUT
-        echo "sublevel=$SUBLEVEL" >> $GITHUB_OUTPUT
-
-    - name: Apply glibc 2.38 Compatibility Fix
-      if: true
-      run: |
-        # Use SUBLEVEL for LTS builds, otherwise use the input sub_level
-        if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] || 
-           [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] || 
-           [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]] || 
-           [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" && $SUBLEVEL -le 43 ]]; then
-          GLIBC_VERSION=$(ldd --version 2>/dev/null | head -n 1 | awk '{print $NF}') 
-          if [ "$(printf '%s\n' "2.38" "$GLIBC_VERSION" | sort -V | head -n1)" = "2.38" ]; then 
-            cd "$GITHUB_WORKSPACE/kernel/common"
-            sed -i '/\$(Q)\$(MAKE) -C \$(SUBCMD_SRC) OUTPUT=\$(abspath \$(dir \$@))\/ \$(abspath \$@)/s//$(Q)$(MAKE) -C $(SUBCMD_SRC) EXTRA_CFLAGS="$(CFLAGS)" OUTPUT=$(abspath $(dir $@))\/ $(abspath $@)/' tools/bpf/resolve_btfids/Makefile 2>/dev/null || true
-            if [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" && $SUBLEVEL -le 186 ]] || 
-               [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 119 ]] || 
-               [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" && $SUBLEVEL -le 110 ]]; then
-              sed -i '/char \*buf = NULL;/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
-              sed -i 's/for (int i = 0; subcommands\[i\]; i++) {/for (i = 0; subcommands[i]; i++) {/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
-              sed -i '/if (subcommands) {/a int i;' tools/lib/subcmd/parse-options.c 2>/dev/null || true
-              sed -i 's/for (int i = 0; subcommands\[i\]; i++)/for (i = 0; subcommands[i]; i++)/' tools/lib/subcmd/parse-options.c 2>/dev/null || true
-            fi
-          fi
-        fi 
+      uses: ./.github/actions/extract-sublevel-file-name
+      with:
+        variant: ${{ matrix.variant }}
 
-    - name: Fix Less Than 6.6.50 Builds
-      if: ${{ steps.parse.outputs.android_version == 'android15' && steps.parse.outputs.kernel_version == '6.6'}}
-      working-directory: ${{ github.workspace }}/kernel/common
-      run: |
-        if ! grep -qxF '#include <trace/hooks/fs.h>' ./fs/namespace.c; then
-            sed -i '/#include <trace\/hooks\/blk.h>/a #include <trace\/hooks\/fs.h>' ./fs/namespace.c
-        fi
+    - name: Kernel Fixes
+      uses: ./.github/actions/kernel-fixes
+      with:
+        android_version: ${{ steps.parse.outputs.android_version }}
+        kernel_version: ${{ steps.parse.outputs.kernel_version }}
+        sublevel: ${{ steps.extract.outputs.sublevel }}
+        os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
 
     - name: Setup KernelSU-Next
       if: contains(inputs.feature_set, 'KSUN')
@@ -220,50 +115,33 @@ jobs:
         sublevel: ${{ steps.extract.outputs.sublevel }}
         susfs_commit: ${{ inputs.susfs_commit }}
 
-    - name: Setup SUSFS Patches
-      if: contains(inputs.feature_set, 'SUSFS')
-      uses: ./.github/actions/susfs-patches
-      with:
-        android_version: ${{ steps.parse.outputs.android_version }}
-        kernel_version: ${{ steps.parse.outputs.kernel_version }}
-        os_patch_level: ${{ steps.parse.outputs.os_patch_level }}
-        sublevel: ${{ steps.extract.outputs.sublevel }}
-
     - name: Setup Baseband Guard
       if: contains(inputs.feature_set, 'BBG')
       uses: ./.github/actions/bbg
 
     - name: Apply Module Check Bypass
       if: ${{ matrix.variant == 'Bypass' }}
-      run: |
-        if [[ "$KERNEL_VERSION" == "6.1" || "$KERNEL_VERSION" == "6.6" || "$KERNEL_VERSION" == "6.12" ]]; then
-          TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module/version.c"
-        else
-          TARGET_FILE="$GITHUB_WORKSPACE/kernel/common/kernel/module.c"
-        fi
-        # Apply bypass patch to the target file
-        sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
-
-        # Verify the bypass
-        if grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
-          echo "SUCCESS: Module check bypass verified in $TARGET_FILE"
-        else
-          echo "FAILED: Module check bypass not found in $TARGET_FILE"
-          grep -A 5 "bad_version:" "$TARGET_FILE" || true
-          exit 1
-        fi
+      uses: ./.github/actions/module-check-bypass
+      with:
+        kernel_version: ${{ steps.parse.outputs.kernel_version }}
 
     - name: Apply Device-Specific Patches
       uses: ./.github/actions/apply-device-patches
       with:
         kernel_version: ${{ steps.parse.outputs.kernel_version }}
 
-    - name: Setup Networking options
+    - name: Setup Networking Configs
       uses: ./.github/actions/networking
       with:
         kernel_version: ${{ steps.parse.outputs.kernel_version }}
         android_version: ${{ steps.parse.outputs.android_version }}
 
+    - name: Setup Misc Configs
+      uses: ./.github/actions/misc
+      with:
+        kernel_version: ${{ steps.parse.outputs.kernel_version }}
+        android_version: ${{ steps.parse.outputs.android_version }}
+
     - name: Apply ABI Compare Bypass
       if: false
       working-directory: ${{ github.workspace }}/kernel
@@ -291,166 +169,51 @@ jobs:
         kernel_version: ${{ steps.parse.outputs.kernel_version }}
 
     - name: Remove Protected Exports
-      working-directory: ${{ github.workspace }}/kernel
-      run: |
-        set -ex
-        if [ ! -f "build/build.sh" ]; then
-          # Bazel build system (newer kernels)
-          # Remove ABI protected exports to prevent build errors
-          rm -rf common/android/abi_gki_protected_exports_*
-          perl -pi -e 's/^\s*"protected_exports_list"\s*:\s*"android\/abi_gki_protected_exports_aarch64",\s*$//;' common/BUILD.bazel
-          sed -i 's/protected_modules = \[.*\]/protected_modules = []/' common/modules.bzl || true
-        fi
+      uses: ./.github/actions/remove-protected-exports
 
     - name: Clean Kernel Flags
       uses: ./.github/actions/clean-kernel-flags
 
     - name: Build Kernel
-      working-directory: ${{ github.workspace }}/kernel
       env:
         SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
         KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
-      run: |
-        set -ex
-        if [ -f "build/build.sh" ]; then
-          #SKIP_MRPROPER=1
-          GKI_DEFCONFIG_FRAGMENT="$GITHUB_WORKSPACE/wild_gki.fragment" BUILD_CONFIG=common/build.config.gki.aarch64 build/build.sh || exit 1
-        else
-          # Copy fragment to kernel tree for bazel
-          cp "$GITHUB_WORKSPACE/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
-          tools/bazel build --config=release --stamp --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment //common:kernel_aarch64_dist || exit 1
-        fi
+      uses: ./.github/actions/build-kernel
 
     - name: Create Bootimgs Folder and Build Boot Images
-      working-directory: ${{ github.workspace }}
-      run: |
-        set -e
-
-        mkdir -p bootimgs
-        mkdir -p boot-artifacts
-
-        echo "Creating bootimgs folder and copying images..."
-        if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
-          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
-          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
-        else
-          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/bootimgs/Image"
-          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image.lz4" "$GITHUB_WORKSPACE/bootimgs/Image.lz4"
-        fi
-        gzip -n -k -f -9 "$GITHUB_WORKSPACE/bootimgs/Image" > "$GITHUB_WORKSPACE/bootimgs/Image.gz"
+      uses: ./.github/actions/build-boot-images
 
-        cd "$GITHUB_WORKSPACE/bootimgs"
-
-        case "$ANDROID_VERSION" in
-          android12)
-            echo "Android 12: downloading certified boot image to extract ramdisk..."
-            GKI_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-${OS_PATCH_LEVEL}_r1.zip"
-            FALLBACK_URL="https://dl.google.com/android/gki/gki-certified-boot-android12-5.10-2023-01_r1.zip"
-
-            echo "Checking if GKI kernel URL is reachable: $GKI_URL"
-            status="$(curl -sL -w "%{http_code}" "$GKI_URL" -o /dev/null || true)"
-
-            if [ "$status" = "200" ]; then
-              echo "Downloading from GKI_URL"
-              curl -L -o gki-kernel.zip "$GKI_URL"
-            else
-              echo "$GKI_URL not found (HTTP $status), using $FALLBACK_URL"
-              curl -L -o gki-kernel.zip "$FALLBACK_URL"
-            fi
-
-            echo "Unzipping the downloaded kernel..."
-            unzip -q gki-kernel.zip
-            rm -f gki-kernel.zip
-
-            echo "Unpacking boot image to extract ramdisk..."
-            if [ -f "./boot-5.10.img" ]; then
-              BOOT_IMG="./boot-5.10.img"
-            else
-              BOOT_IMG="$(ls -1 ./boot-*.img 2>/dev/null | head -n 1 || true)"
-            fi
-
-            if [ -z "${BOOT_IMG:-}" ]; then
-              echo "Error: could not find extracted boot-*.img in $PWD"
-              ls -la
-              exit 1
-            fi
-
-            "$UNPACK_BOOTIMG" --boot_img="$PWD/$BOOT_IMG"
-            ;;
-        esac
-
-        for kernel_image in Image Image.gz Image.lz4; do
-          case "$kernel_image" in
-            Image) output_image="boot.img" ;;
-            Image.gz) output_image="boot-gz.img" ;;
-            Image.lz4) output_image="boot-lz4.img" ;;
-          esac
-
-          echo "Building $output_image"
-          if [ "$ANDROID_VERSION" = "android12" ]; then
-            "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image" --ramdisk out/ramdisk --os_version 12.0.0 --os_patch_level "$OS_PATCH_LEVEL"
-          else
-            "$MKBOOTIMG" --header_version 4 --kernel "$kernel_image" --output "$output_image"
-          fi
+    - name: Upload Boot Image (boot.img)
+      uses: actions/upload-artifact@v7
+      with:
+        path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot.img
+        if-no-files-found: error
+        archive: false
 
-          "$AVBTOOL" add_hash_footer --partition_name boot --partition_size $((64 * 1024 * 1024)) --image "$output_image" --algorithm SHA256_RSA2048 --key "$BOOT_SIGN_KEY_PATH"
-          cp "$output_image" "$GITHUB_WORKSPACE/boot-artifacts/${FILE_NAME}-${output_image}"
-        done
+    - name: Upload Boot Image (boot-gz.img)
+      uses: actions/upload-artifact@v7
+      with:
+        path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-gz.img
+        if-no-files-found: error
+        archive: false
 
-    - name: Upload Boot Images
-      uses: actions/upload-artifact@v5
+    - name: Upload Boot Image (boot-lz4.img)
+      uses: actions/upload-artifact@v7
       with:
-        name: ${{ steps.extract.outputs.file_name }}-BootImages
-        path: ${{ github.workspace }}/boot-artifacts/*.img
+        path: ${{ github.workspace }}/boot-artifacts/${{ steps.extract.outputs.file_name }}-boot-lz4.img
         if-no-files-found: error
-        compression-level: 0
+        archive: false
 
     - name: Prepare AnyKernel3 Zip
-      run: |
-        # Copy Image from normal build locations
-        if [ -f "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" ]; then
-          cp "$GITHUB_WORKSPACE/kernel/out/$ANDROID_VERSION-$KERNEL_VERSION/dist/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
-        elif [ -f "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" ]; then
-          cp "$GITHUB_WORKSPACE/kernel/bazel-bin/common/kernel_aarch64/Image" "$GITHUB_WORKSPACE/AnyKernel3/Image"
-        else
-          echo "Error: Image file not found in any expected location"
-          exit 1
-        fi
+      uses: ./.github/actions/prepare-anykernel3
 
     - name: Scan and collect patch rejects
       id: scan
       if: ${{ always() }}
-      run: |
-        set -e
-        CONFIG_DIR="$GITHUB_WORKSPACE/kernel"
-        REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
-        mkdir -p "$REJECTS_DIR"
-        # Find all .rej files under the configuration directory
-        mapfile -t REJS < <(find "$CONFIG_DIR" -type f -name '*.rej')
-        REJ_COUNT=${#REJS[@]}
-        echo "Found $REJ_COUNT .rej files under $CONFIG_DIR"
-        echo "REJ_COUNT=$REJ_COUNT" >> $GITHUB_ENV
-        echo "rej_count=$REJ_COUNT" >> $GITHUB_OUTPUT
-        if [ "$REJ_COUNT" -gt 0 ]; then
-          for REJ in "${REJS[@]}"; do
-            # Relative path from $CONFIG
-            REL="${REJ#"$CONFIG_DIR"/}"
-            DEST="$REJECTS_DIR/$REL"
-            mkdir -p "$(dirname "$DEST")"
-            cp "$REJ" "$DEST"
-            # Copy the associated original file alongside the .rej
-            ORIG="${REJ%.rej}"
-            if [ -f "$ORIG" ]; then
-              ORIG_DEST="$REJECTS_DIR/${REL%.rej}"
-              mkdir -p "$(dirname "$ORIG_DEST")"
-              cp "$ORIG" "$ORIG_DEST"
-            fi
-            echo "$REL" >> "$REJECTS_DIR/index.txt"
-          done
-        fi
+      uses: ./.github/actions/scan-patch-rejects
 
     - name: Upload Artifacts
-      uses: actions/upload-artifact@v5
+      uses: actions/upload-artifact@v7
       with:
         name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
         path: ${{ github.workspace }}/AnyKernel3/**
@@ -459,7 +222,7 @@ jobs:
 
     - name: Upload Rejects
       if: ${{ always() }}
-      uses: actions/upload-artifact@v5
+      uses: actions/upload-artifact@v7
       with:
         name: ${{ steps.extract.outputs.file_name }}-Rejects
         path: patch-rejects/

+ 4 - 4
.github/workflows/main.yml

@@ -166,7 +166,7 @@ jobs:
 
     steps:
     - name: Download Misc Artifacts
-      uses: actions/download-artifact@v5
+      uses: actions/download-artifact@v7
       with:
         path: ./downloaded-artifacts
         pattern: '*-Rejects'
@@ -210,7 +210,7 @@ jobs:
         fi
 
     - name: Upload AIO-REJ Artifact
-      uses: actions/upload-artifact@v5
+      uses: actions/upload-artifact@v7
       with:
         name: AIO-REJ
         path: AIO-REJ.zip
@@ -441,14 +441,14 @@ jobs:
         done
 
     - name: Download AnyKernel3 Artifacts
-      uses: actions/download-artifact@v5
+      uses: actions/download-artifact@v7
       with:
         path: release-assets
         pattern: '*-AnyKernel3'
         merge-multiple: false
 
     - name: Download Boot Image Artifacts
-      uses: actions/download-artifact@v5
+      uses: actions/download-artifact@v7
       with:
         path: release-assets
         pattern: '*-BootImages'