| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348 |
- name: Kernel Build Process
- permissions:
- contents: write
- actions: write
- on:
- workflow_call:
- inputs:
- version:
- required: true
- type: string
- android_version:
- required: true
- type: string
- kernel_version:
- required: true
- type: string
- sublevel:
- required: true
- type: string
- os_patch_level:
- required: true
- type: string
- variant:
- required: false
- type: string
- feature_set:
- required: true
- type: string
- use_repo:
- required: false
- type: boolean
- use_latest_commits:
- required: false
- type: boolean
- default: true
- jobs:
- build-gki:
- name: "${{ inputs.kernel_version }}.${{ inputs.sublevel }}-${{ inputs.android_version }}-${{ inputs.os_patch_level }} (${{ inputs.variant }})"
- runs-on: ubuntu-latest
- timeout-minutes: 60
- steps:
- - name: Checkout Repository
- uses: actions/checkout@v5
- - name: 🧹 Emergency Disk Cleanup
- if: false
- uses: ./.github/actions/disk-cleanup
- - name: Free Disk Space
- if: true
- uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
- with:
- remove_android: true
- remove_dotnet: true
- remove_haskell: true
- remove_tool_cache: true
- remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
- remove_packages_one_command: true
- remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
- rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
- rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
- testing: false
- - name: Setup more Swap (for LTO)
- uses: thejerrybao/setup-swap-space@v1 # or pierotofy/set-swap-space
- with:
- swap-size-gb: 10 # 10-24 GB is common for heavy LTO
- # swap-space-path: /mnt/swapfile # optional
- - name: Setup Build Environment
- uses: ./.github/actions/setup-build-environment
- env:
- BOOT_SIGN_KEY: ${{ secrets.BOOT_SIGN_KEY }}
-
- - name: Download Kernel Repository
- uses: ./.github/actions/download-kernel
- with:
- version: ${{ inputs.version }}
- android_version: ${{ inputs.android_version }}
- kernel_version: ${{ inputs.kernel_version }}
- os_patch_level: ${{ inputs.os_patch_level }}
- use_repo: ${{ inputs.use_repo }}
- - name: Set Build Timestamp from Kernel Commit
- shell: bash
- run: |
- set -x
- # Hardcode the build timestamp to the 5th day of the patch level
- # at 04:20 UTC, using the existing timestamp formats expected by the build.
- OS_PATCH_LEVEL_INPUT="${{ inputs.os_patch_level }}"
- if [[ "$OS_PATCH_LEVEL_INPUT" == lts* ]]; then
- if [[ "$OS_PATCH_LEVEL_INPUT" =~ ^lts-([0-9]{2})$ ]]; then
- OS_PATCH_LEVEL_YM="$(date -u +%Y)-${BASH_REMATCH[1]}"
- else
- OS_PATCH_LEVEL_YM="$(date -u +%Y-%m)"
- fi
- else
- OS_PATCH_LEVEL_YM="$OS_PATCH_LEVEL_INPUT"
- fi
- FIXED_BUILD_DATE="${OS_PATCH_LEVEL_YM}-05 04:20:00 UTC"
- SOURCE_DATE_EPOCH=$(date -u -d "$FIXED_BUILD_DATE" +%s)
- echo "SOURCE_DATE_EPOCH=$SOURCE_DATE_EPOCH" >> $GITHUB_ENV
- KBUILD_TS=$(date -u -d @${SOURCE_DATE_EPOCH} '+%a %b %d %H:%M:%S UTC %Y')
- echo "KBUILD_BUILD_TIMESTAMP=${KBUILD_TS}" >> $GITHUB_ENV
- # Keep git metadata aligned with the same fixed timestamp.
- GIT_DATE=$(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%dT%H:%M:%SZ')
- echo "GIT_COMMITTER_DATE=${GIT_DATE}" >> $GITHUB_ENV
- echo "GIT_AUTHOR_DATE=${GIT_DATE}" >> $GITHUB_ENV
- echo "Build timestamp set to: $(date -u -d @${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S UTC') (epoch: $SOURCE_DATE_EPOCH)"
- - name: Extract Sublevel and Set File Name
- id: extract
- uses: ./.github/actions/extract-sublevel-file-name
- with:
- android_version: ${{ inputs.android_version }}
- kernel_version: ${{ inputs.kernel_version }}
- sublevel: ${{ inputs.sublevel }}
- os_patch_level: ${{ inputs.os_patch_level }}
- variant: ${{ inputs.variant }}
- - name: Kernel Fixes
- uses: ./.github/actions/kernel-fixes
- with:
- version: ${{ inputs.version }}
- android_version: ${{ inputs.android_version }}
- kernel_version: ${{ inputs.kernel_version }}
- sublevel: ${{ steps.extract.outputs.sublevel }}
- os_patch_level: ${{ inputs.os_patch_level }}
- - name: Setup KernelSU-Next
- if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
- uses: ./.github/actions/kernelsu
- with:
- use_latest_commits: ${{ inputs.use_latest_commits }}
- - name: SUSFS
- if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
- uses: ./.github/actions/susfs
- with:
- use_latest_commits: ${{ inputs.use_latest_commits }}
- version: ${{ inputs.version }}
- android_version: ${{ inputs.android_version }}
- kernel_version: ${{ inputs.kernel_version }}
- os_patch_level: ${{ inputs.os_patch_level }}
- sublevel: ${{ steps.extract.outputs.sublevel }}
- - name: Baseband Guard
- if: (contains(inputs.feature_set, 'BBG') || inputs.feature_set == 'FULL')
- uses: ./.github/actions/bbg
- - name: Setup Networking
- if: contains(inputs.feature_set, 'NET') || inputs.feature_set == 'FULL'
- uses: ./.github/actions/networking
- with:
- kernel_version: ${{ inputs.kernel_version }}
- android_version: ${{ inputs.android_version }}
- - name: DroidSpaces-OSS Patches
- if: contains(inputs.feature_set, 'DS') || inputs.feature_set == 'FULL'
- uses: ./.github/actions/droidspaces
- with:
- version: ${{ inputs.version }}
- kernel_version: ${{ inputs.kernel_version }}
- - name: Setup Misc Configs
- uses: ./.github/actions/misc
- with:
- version: ${{ inputs.version }}
- kernel_version: ${{ inputs.kernel_version }}
- android_version: ${{ inputs.android_version }}
- sublevel: ${{ steps.extract.outputs.sublevel }}
- variant: ${{ inputs.variant }}
- - name: Apply Device-Specific Patches
- uses: ./.github/actions/apply-device-patches
- with:
- version: ${{ inputs.version }}
- kernel_version: ${{ inputs.kernel_version }}
- - name: Apply ABI Compare Bypass
- if: false
- working-directory: ${{ github.workspace }}/kernel
- run: |
- # ABI compare bypass per kernel/android version
- # Edit each block as needed per version
- if [[ "$ANDROID_VERSION" == "android12" && "$KERNEL_VERSION" == "5.10" ]]; then
- sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/abi/compare_to_symbol_list
- elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.10" ]]; then
- sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
- elif [[ "$ANDROID_VERSION" == "android13" && "$KERNEL_VERSION" == "5.15" ]]; then
- sed -i 's/^\s*exit 1$/ echo "Who Cares? Bypassing Now!"/' build/kernel/abi/compare_to_symbol_list
- elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "5.15" ]]; then
- perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
- elif [[ "$ANDROID_VERSION" == "android14" && "$KERNEL_VERSION" == "6.1" ]]; then
- perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
- elif [[ "$ANDROID_VERSION" == "android15" && "$KERNEL_VERSION" == "6.6" ]]; then
- perl -i -pe 's/^(\s*)return 1$/$1print("Who Cares? Bypassing Now!")\n$1return 0/g if /if missing_symbols:/../return 1/' build/kernel/abi/check_buildtime_symbol_protection.py
- fi
- - name: Apply Kernel Branding
- uses: ./.github/actions/apply-kernel-branding
- with:
- variant: ${{ inputs.variant }}
- kernel_version: ${{ inputs.kernel_version }}
- android_version: ${{ inputs.android_version }}
- version: ${{ inputs.version }}
- sublevel: ${{ steps.extract.outputs.sublevel }}
- - name: Remove Protected Exports
- uses: ./.github/actions/remove-protected-exports
- - name: Clean Kernel Flags
- uses: ./.github/actions/clean-kernel-flags
- - name: Scan and collect patch rejects
- id: scan
- if: ${{ always() }}
- uses: ./.github/actions/scan-patch-rejects
-
- - name: Upload Rejects
- if: ${{ always() }}
- uses: actions/upload-artifact@v7
- with:
- name: ${{ steps.extract.outputs.file_name }}-Rejects
- path: patch-rejects/
- if-no-files-found: ignore
- compression-level: 9
- - name: 'Setup Cache and Build Environment'
- uses: ./.github/actions/cache-setup
- with:
- version: ${{ inputs.version }}
- android_version: ${{ inputs.android_version }}
- kernel_version: ${{ inputs.kernel_version }}
- sublevel: ${{ steps.extract.outputs.sublevel }}
- - name: Restore ccache
- id: restore-ccache
- if: inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15'
- uses: ./.github/actions/cache-restore
- with:
- cache_path: /home/runner/.ccache
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: ccache-cache
- restore_keys: |
- ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
- - name: Restore lto-cache (ccache versions)
- id: restore-lto-ccache
- if: inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15'
- uses: ./.github/actions/cache-restore
- with:
- cache_path: /home/runner/.ld_cache
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: lto-cache
- restore_keys: |
- ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
- - name: Restore bazel-cache
- id: restore-bazel
- if: inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12'
- uses: ./.github/actions/cache-restore
- with:
- cache_path: /home/runner/.cache/bazel
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: bazel-cache
- restore_keys: |
- ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-
- - name: Check cache hit
- run: |
- echo "Cache restore status:" CCACHE_HIT="${{ steps.restore-ccache.outputs.cache-hit || 'skipped' }}"
- LTO_CCACHE_HIT="${{ steps.restore-lto-ccache.outputs.cache-hit || 'skipped' }}"
- BAZEL_HIT="${{ steps.restore-bazel.outputs.cache-hit || 'skipped' }}"
- LTO_BAZEL_HIT="${{ steps.restore-lto-bazel.outputs.cache-hit || 'skipped' }}"
- echo " ccache: $CCACHE_HIT"
- echo " lto (ccache versions): $LTO_CCACHE_HIT"
- echo " bazel: $BAZEL_HIT"
- echo " lto (bazel versions): $LTO_BAZEL_HIT"
- - name: Get Cache Stats
- uses: ./.github/actions/cache-stats
- with:
- clear_stats: true
- - name: Build Normal Kernel
- env:
- SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
- KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
- uses: ./.github/actions/build-kernel
- with:
- version: ${{ inputs.version }}
- bypass: false
- - name: Get Cache Stats
- uses: ./.github/actions/cache-stats
- with:
- clear_stats: false
- - name: Save ccache
- uses: ./.github/actions/cache-save
- if: inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15'
- with:
- cache_path: /home/runner/.ccache
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: "ccache-cache"
- compression_level: 9
- github_token: ${{ secrets.MY_GITHUB_TOKEN }}
- - name: Save lto-cache
- uses: ./.github/actions/cache-save
- if: inputs.version == 'android12-5.10' || inputs.version == 'android13-5.10' || inputs.version == 'android13-5.15'
- with:
- cache_path: /home/runner/.ld_cache
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: "lto-cache"
- compression_level: 9
- github_token: ${{ secrets.MY_GITHUB_TOKEN }}
- - name: Save bazel-cache
- uses: ./.github/actions/cache-save
- if: inputs.version == 'android14-5.15' || inputs.version == 'android14-6.1' || inputs.version == 'android15-6.6' || inputs.version == 'android16-6.12'
- with:
- cache_path: /home/runner/.cache/bazel
- cache_key: ${{ inputs.android_version }}-${{ inputs.kernel_version }}.${{ steps.extract.outputs.sublevel }}-${{ inputs.os_patch_level }}
- cache_bucket: "bazel-cache"
- compression_level: 9
- github_token: ${{ secrets.MY_GITHUB_TOKEN }}
- - name: Build Bypass Kernel
- env:
- SOURCE_DATE_EPOCH: ${{ env.SOURCE_DATE_EPOCH }}
- KBUILD_BUILD_TIMESTAMP: ${{ env.KBUILD_BUILD_TIMESTAMP }}
- uses: ./.github/actions/build-kernel
- with:
- bypass: true
- version: ${{ inputs.version }}
- - name: Upload Artifacts
- uses: actions/upload-artifact@v7
- with:
- name: ${{ steps.extract.outputs.file_name }}-AnyKernel3
- path: ${{ github.workspace }}/AnyKernel3/**
- if-no-files-found: ignore
- compression-level: 9
|