| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497 |
- name: Kernel Build Process
- permissions:
- contents: write
- actions: write
- on:
- workflow_call:
- inputs:
- branch:
- required: true
- type: string
- build_type:
- required: false
- type: string
- root_flavor:
- description: "next / kernelsu / resukisu"
- required: false
- type: string
- default: "next"
- root_commit:
- required: false
- type: string
- default: ""
- variant:
- required: false
- type: string
- default: ""
- susfs_commit:
- required: false
- type: string
- default: ""
- susfs_commit_android12_5_10:
- required: false
- type: string
- default: ""
- susfs_commit_android13_5_10:
- required: false
- type: string
- default: ""
- susfs_commit_android13_5_15:
- required: false
- type: string
- default: ""
- susfs_commit_android14_5_15:
- required: false
- type: string
- default: ""
- susfs_commit_android14_6_1:
- required: false
- type: string
- default: ""
- susfs_commit_android15_6_6:
- required: false
- type: string
- default: ""
- susfs_commit_android16_6_12:
- required: false
- type: string
- default: ""
- nomount_commit:
- required: false
- type: string
- default: ""
- susfs:
- required: true
- type: string
- bbg:
- required: true
- type: string
- unicodefix:
- required: true
- type: string
- zeromount:
- required: true
- type: string
- nomount:
- required: true
- type: string
- droidspace:
- required: true
- type: string
- ntsync:
- required: true
- type: string
- bbrv3:
- required: true
- type: string
- cache:
- required: true
- type: string
- ipv6_nat:
- required: true
- type: string
- optimization:
- required: true
- type: string
- ttl:
- required: true
- type: string
- lto:
- required: true
- type: string
- kpm:
- required: true
- type: string
- jobs:
- build-samsung-gki:
- name: "${{ inputs.branch }} (${{ inputs.variant || inputs.root_flavor }})"
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- steps:
- - name: Checkout Repository
- uses: actions/checkout@v5
-
- - name: Store branch as env variable
- run: BRANCH=${{ inputs.branch }} && echo "BRANCH=$BRANCH" >> $GITHUB_ENV
- - name: get kernel version before cloning
- uses: ./.github/actions/kernel-info
- - name: Store LTO as env variable
- run: |
- if [[ $KERNEL_VER != 6.6 ]]; then
- BUILD_LTO=${{ inputs.lto }} && echo "BUILD_LTO=$BUILD_LTO" >> $GITHUB_ENV
- else
- BUILD_LTO="default" && echo "BUILD_LTO=$BUILD_LTO" >> $GITHUB_ENV
- fi
-
- - name: Free Disk Space
- if: true
- uses: endersonmenezes/free-disk-space@v3
- with:
- remove_android: true
- remove_dotnet: true
- remove_haskell: true
- remove_tool_cache: true
- remove_swap: 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"
- rmz_version: "3.1.1"
- testing: false
- - name: Setup more Swap (for LTO)
- uses: pierotofy/set-swap-space@master
- with:
- swap-size-gb: 25
- - name: Parse branch for cache keys
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- uses: ./.github/actions/parse-branch
- - name: Install ccache
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- run: sudo apt-get update && sudo apt-get install -y ccache
-
- - name: Export ccache + determinism
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- run: |
- CACHE_DIR="${{ github.workspace }}/.ccache"
- mkdir -p "$CACHE_DIR"
- CCACHE_LOG="${{ github.workspace }}/ccache.log"
-
- SETTINGS=(
- "CCACHE_DIR=$CACHE_DIR"
- "CCACHE_MAXSIZE=12G"
- "CCACHE_COMPILERCHECK=content"
- "CCACHE_BASEDIR=${GITHUB_WORKSPACE}"
- "CCACHE_NOHASHDIR=true"
- "CCACHE_IGNOREOPTIONS=-sysroot* -fdebug-prefix-map=* -fmacro-prefix-map=*"
- "CCACHE_COMPRESS=true"
- "CCACHE_COMPRESSLEVEL=8"
- "CCACHE_DIRECT=true"
- "CCACHE_FILE_CLONE=true"
- "CCACHE_INODE_CACHE=true"
- "CCACHE_IS_KERNEL_COMPILING=true"
- "CCACHE_UMASK=002"
- "KBUILD_BUILD_TIMESTAMP=2026-01-01"
- "CCACHE_SLOPPINESS=file_macro,time_macros,include_file_mtime,include_file_ctime,pch_defines,system_headers,locale,file_stat_matches"
- )
- for setting in "${SETTINGS[@]}"; do
- export "$setting"
- echo "$setting" >> $GITHUB_ENV
- done
- if ccache --help 2>&1 | grep -q 'depend_mode'; then
- export CCACHE_DEPEND=true
- echo "CCACHE_DEPEND=true" >> "$GITHUB_ENV"
- fi
- - name: restore ccache
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- uses: actions/cache@v6
- with:
- path: ${{ env.CCACHE_DIR }}
- key: ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-${{ inputs.root_flavor }}-${{ inputs.variant }}
- restore-keys: |
- ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-${{ inputs.root_flavor }}-
- ccache-${{ runner.os }}-${{ inputs.build_type }}-${{ env.BASE_BRANCH }}-
- ccache-${{ runner.os }}-${{ inputs.build_type }}-
-
- - name: Ensure ccache is used
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- run: |
- echo "/usr/lib/ccache" >> $GITHUB_PATH
- echo "CC='ccache clang'" >> $GITHUB_ENV
- echo "CXX='ccache clang++'" >> $GITHUB_ENV
-
- - name: Set CONFIG Environment Variable
- run: |
- CONFIG="$BRANCH-${ANDROID_VER}_${KERNEL_VER}"
- echo "CONFIG=$CONFIG" >> $GITHUB_ENV
- - name: dependencies
- uses: ./.github/actions/dependencies
-
- - name: Download Kernel
- uses: ./.github/actions/clone-kernel
-
- - name: Set Path Environment Variables
- uses: ./.github/actions/env-variables
-
- - name: Extract all tar.xz files and delete them
- run: |
- cd "$CONFIG"
- find . -type f -name '*.tar.xz' -print0 | while IFS= read -r -d '' file; do
- echo "Extracting $file"
- tar -xf "$file"
- rm "$file"
- done
- - name: Setup Selected Root Implementation
- if: inputs.root_flavor != ''
- uses: ./.github/actions/root-setup
- with:
- flavor: ${{ inputs.root_flavor }}
- commit: ${{ inputs.root_commit }}
- - name: Disable SUSFS for ReSukiSU without SUSFS feature
- if: inputs.root_flavor == 'resukisu' && inputs.susfs != 'true'
- run: |
- "$COMMON/scripts/config" --file "$GKI_DEFCONFIG" --disable CONFIG_KSU_SUSFS || true
- echo "Disabled SUSFS for resukisu without SUSFS"
- - name: Resolve SUSFS commit
- id: susfs-cm
- if: inputs.susfs == 'true'
- shell: bash
- run: |
- set -euo pipefail
- # KernelSU-Next (next) always uses latest tip so SUSFS stays API-matched.
- # Other flavors use pinned verified commit per kernel version.
- # We receive all per-version pins from kernel-samsung.yml inputs.
- KVER="$KERNEL_VER"
- AVER="$ANDROID_VER"
- echo "KERNEL_VER=$KVER ANDROID_VER=$AVER root_flavor=${{ inputs.root_flavor }}"
- pick_pin() {
- case "$KVER" in
- 5.10) if [ "$AVER" = "android12" ]; then echo "${{ inputs.susfs_commit_android12_5_10 }}"; else echo "${{ inputs.susfs_commit_android13_5_10 }}"; fi ;;
- 5.15) if [ "$AVER" = "android14" ]; then echo "${{ inputs.susfs_commit_android14_5_15 }}"; else echo "${{ inputs.susfs_commit_android13_5_15 }}"; fi ;;
- 6.1) echo "${{ inputs.susfs_commit_android14_6_1 }}" ;;
- 6.6) echo "${{ inputs.susfs_commit_android15_6_6 }}" ;;
- 6.12) echo "${{ inputs.susfs_commit_android16_6_12 }}" ;;
- *) echo "${{ inputs.susfs_commit }}" ;;
- esac
- }
- if [ "${{ inputs.root_flavor }}" = "next" ]; then
- BRANCH="gki-${AVER}-${KVER}"
- # try android version fallback if branch missing
- SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${BRANCH}" | cut -f1)"
- if [ -z "$SUSFS_COMMIT" ]; then
- # fallback to generic gki branch
- for b in "gki-android12-5.10" "gki-android13-5.15" "gki-android14-6.1" "gki-android15-6.6"; do
- SUSFS_COMMIT="$(git ls-remote https://gitlab.com/simonpunk/susfs4ksu.git "refs/heads/${b}" | cut -f1 || true)"
- [ -n "$SUSFS_COMMIT" ] && break
- done
- fi
- # last resort: use pinned
- if [ -z "$SUSFS_COMMIT" ]; then SUSFS_COMMIT="$(pick_pin)"; fi
- echo "KernelSU-Next: resolving SUSFS at latest on ${BRANCH} -> ${SUSFS_COMMIT}"
- else
- SUSFS_COMMIT="$(pick_pin)"
- if [ -z "$SUSFS_COMMIT" ]; then SUSFS_COMMIT="${{ inputs.susfs_commit }}"; fi
- echo "Using pinned SUSFS commit: ${SUSFS_COMMIT}"
- fi
- echo "commit=${SUSFS_COMMIT}" >> "$GITHUB_OUTPUT"
- echo "SUSFS_COMMIT=${SUSFS_COMMIT}" >> "$GITHUB_ENV"
- - name: Add SUSFS
- if: inputs.susfs == 'true'
- uses: ./.github/actions/susfs-patches
- with:
- nomount: ${{ inputs.nomount }}
- susfs_commit: ${{ steps.susfs-cm.outputs.commit }}
- - name: Add Zeromount
- if: inputs.susfs == 'true' && inputs.zeromount == 'true'
- uses: ./.github/actions/zeromount
- - name: add nomount
- if: inputs.nomount == 'true'
- uses: ./.github/actions/nomount
- with:
- commit: ${{ inputs.nomount_commit }}
- - name: Add BBG
- if: inputs.bbg == 'true'
- uses: ./.github/actions/bbg
- - name: Add unicodefix
- if: inputs.unicodefix == 'true'
- uses: ./.github/actions/unicode
- - name: Add droidspace support
- if: inputs.droidspace == 'true'
- uses: ./.github/actions/droidspaces
- - name: Add ntsync
- if: inputs.ntsync == 'true'
- uses: ./.github/actions/ntsync
-
- - name: Add bbrv3
- if: inputs.bbrv3 == 'true'
- uses: ./.github/actions/bbrv3
- - name: Add IP-SET and IPv6_NAT support
- if: inputs.ipv6_nat == 'true'
- uses: ./.github/actions/IPv6_NAT
- - name: Add TTL support
- if: inputs.ttl == 'true'
- uses: ./.github/actions/TTL
- - name: add optimization patches
- if: inputs.optimization == 'true' && !startsWith(env.BRANCH, 'SM-S711')
- uses: ./.github/actions/optimization
- - name: Fix WiFi and Bluetooth on Samsung 6.6 GKI devices
- if: ${{ env.KERNEL_VER == '6.6' }}
- uses: ./.github/actions/6.6-fix
- - name: temp fix for m55 bootloop maybe
- if: inputs.branch == 'SM-M556B-Oneui8'
- uses: ./.github/actions/m55-fix
- - name: Set Kernel Configuration Variables
- uses: ./.github/actions/configs
- with:
- kpm: ${{ inputs.kpm }}
-
- - name: Change Kernel Name and clean dirty
- uses: ./.github/actions/kernel-name
- - name: remove protected exports
- uses: ./.github/actions/abi-export
-
- - name: Set file name
- uses: ./.github/actions/file-name
- with:
- root_flavor: ${{ inputs.root_flavor }}
- variant: ${{ inputs.variant }}
- ksun: "true"
- susfs: ${{ inputs.susfs }}
- zeromount: ${{ inputs.zeromount }}
- nomount: ${{ inputs.nomount }}
- bbg: ${{ inputs.bbg }}
- bbrv3: ${{ inputs.bbrv3 }}
- droidspaces: ${{ inputs.droidspace }}
- ntsync: ${{ inputs.ntsync }}
- ipv6_nat: ${{ inputs.ipv6_nat }}
- ttl: ${{ inputs.ttl }}
- unicodefix: ${{ inputs.unicodefix }}
-
- - name: change variables to ccache
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- uses: ./.github/actions/use-ccache
- - name: configure LTO
- uses: ./.github/actions/lto
-
- - name: Build
- uses: ./.github/actions/build
- with:
- build_type: ${{ inputs.build_type }}
- - name: clean up ccache
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- run: ccache -c
-
- - name: ccache stats
- if: inputs.cache == 'true' && inputs.build_type == 'make'
- run: ccache -s -v || ccache -s
-
- - name: Prepare AnyKernel3
- uses: ./.github/actions/ak3zip-prep
- - name: modify image for KPM support for ResukiSU
- if: inputs.root_flavor == 'resukisu' && inputs.kpm == 'true'
- uses: ./.github/actions/kpm
- - name: Upload AnyKernel3 Artifacts
- id: upload_ak3
- uses: actions/upload-artifact@v6
- with:
- name: ${{ env.FILE_NAME }}-AnyKernel3
- path: |
- ./AnyKernel3/**
- compression-level: 9
-
- - name: Scan and collect patch rejects
- if: ${{ always() }}
- run: |
- set -e
- CONFIG_DIR="$CONFIG"
- REJECTS_DIR="$GITHUB_WORKSPACE/patch-rejects"
- mkdir -p "$REJECTS_DIR"
- 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
- 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
- - name: Generate Build Summary
- if: ${{ always() }}
- run: |
- echo "# Kernel Build Summary" > build_summary.md
- echo "## ${{ env.FILE_NAME }}" >> build_summary.md
- echo "## Build Information" >> build_summary.md
- echo "- **Branch**: ${{ inputs.branch }}" >> build_summary.md
- echo "- **Root**: ${{ inputs.variant || inputs.root_flavor }} @ ${{ inputs.root_commit }}" >> build_summary.md
- echo "- **Kernel Version**: ${{ env.KERNEL_VER }}" >> build_summary.md
- echo "- **Android Version**: ${{ env.ANDROID_VER }}" >> build_summary.md
- echo "- **SUSFS**: ${{ env.SUSFS_COMMIT || 'disabled' }}" >> build_summary.md
- echo "- **BBG**: Installed" >> build_summary.md
- echo "" >> build_summary.md
- if [ -d "$CONFIG/KernelSU-Next" ]; then
- cd "$CONFIG/KernelSU-Next"
- KSUN_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
- echo "- **KernelSU-Next**: $KSUN_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
- cd "$GITHUB_WORKSPACE"
- elif [ -d "$CONFIG/KernelSU" ]; then
- cd "$CONFIG/KernelSU"
- KSU_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
- echo "- **KernelSU**: $KSU_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
- cd "$GITHUB_WORKSPACE"
- elif [ -d "$CONFIG/ReSukiSU" ]; then
- cd "$CONFIG/ReSukiSU"
- RS_COMMIT=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
- echo "- **ReSukiSU**: $RS_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
- cd "$GITHUB_WORKSPACE"
- fi
-
- if [ -d "$CONFIG/Baseband-guard" ]; then
- cd "$CONFIG/Baseband-guard"
- BBG_COMMIT=$(git rev-parse HEAD)
- echo "- **Baseband-guard**: $BBG_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
- cd "$GITHUB_WORKSPACE"
- fi
-
- if [ -d "$GITHUB_WORKSPACE/susfs4ksu" ]; then
- cd "$GITHUB_WORKSPACE/susfs4ksu"
- SUSFS_COMMIT=$(git rev-parse HEAD)
- echo "- **SUSFS4KSU**: $SUSFS_COMMIT" >> "$GITHUB_WORKSPACE/build_summary.md"
- cd "$GITHUB_WORKSPACE"
- fi
- echo "" >> build_summary.md
-
- echo "## Build Artifacts" >> build_summary.md
- if [ -d "AnyKernel3" ] && [ -f "AnyKernel3/Image" ]; then
- AK3_STATUS="✅"
- else
- AK3_STATUS="❌"
- fi
- echo "- **AnyKernel3**: $AK3_STATUS ${{ env.FILE_NAME }}-AnyKernel3" >> build_summary.md
|