action.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. name: 'Build Kernel'
  2. description: 'Builds kernel using legacy build.sh or Bazel (kleaf)'
  3. inputs:
  4. bypass:
  5. description: 'Whether to add the bypass hack or not'
  6. required: true
  7. version:
  8. description: 'Kernel config version (e.g., android14-6.1)'
  9. required: true
  10. runs:
  11. using: composite
  12. steps:
  13. - name: 'Build Kernel'
  14. shell: bash
  15. working-directory: ${{ github.workspace }}/kernel
  16. run: |
  17. set -euo pipefail
  18. if [ "${{ inputs.bypass }}" = "true" ]; then
  19. if [[ ${{ inputs.version }} == "android14-6.1" || ${{ inputs.version }} == "android15-6.6" || ${{ inputs.version }} == "android16-6.12" ]]; then
  20. TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module/version.c"
  21. else
  22. TARGET_FILE="${{ github.workspace }}/kernel/common/kernel/module.c"
  23. fi
  24. sed -i '/bad_version:/{:a;n;/return 0;/{s/return 0;/return 1;/;b};ba}' "$TARGET_FILE"
  25. if ! grep -A 5 "bad_version:" "$TARGET_FILE" | grep -q "return 1;"; then
  26. echo "Patch failed! 'return 1;' not found at bad_version:"
  27. grep -A 10 "bad_version:" "$TARGET_FILE" || true
  28. exit 1
  29. fi
  30. else
  31. echo "Bypass hack not applied as per input parameter."
  32. fi
  33. # Strip trailing empty lines from gki_defconfig to match savedefconfig output
  34. # (savedefconfig strips trailing newlines, causing check_defconfig to fail on 5.10.233+)
  35. perl -pi -e 's/\n*\z/\n/' common/arch/arm64/configs/gki_defconfig
  36. cp "${{ github.workspace }}/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  37. if [ -f "build/build.sh" ]; then
  38. BUILD_GKI_ARTIFACTS= \
  39. BUILD_GKI_CERTIFICATION_TOOLS=0 \
  40. BUILD_SYSTEM_DLKM=0 \
  41. SKIP_VENDOR_BOOT=1 \
  42. SKIP_EXT_MODULES=1 \
  43. SKIP_CP_KERNEL_HDR=1 \
  44. OUT_DIR="/home/runner/out" \
  45. LTO=thin \
  46. BUILD_CONFIG=common/build.config.gki.aarch64 \
  47. PRE_DEFCONFIG_CMDS="KCONFIG_CONFIG=\${ROOT_DIR}/common/arch/arm64/configs/gki_defconfig \${ROOT_DIR}/common/scripts/kconfig/merge_config.sh -m -r \${ROOT_DIR}/common/arch/arm64/configs/gki_defconfig \${ROOT_DIR}/common/arch/arm64/configs/wild_gki.fragment" \
  48. build/build.sh -j"$(nproc)" \
  49. CC="/usr/bin/ccache clang" \
  50. CXX="/usr/bin/ccache clang+" \
  51. HOSTCC="/usr/bin/ccache clang" \
  52. HOSTCXX="/usr/bin/ccache clang+" \
  53. LD="${{ github.workspace }}/kernel/common/ld-wrapper" \
  54. HOSTLD="${{ github.workspace }}/kernel/common/ld-wrapper"
  55. else
  56. tools/bazel info output_base
  57. cp "${{ github.workspace }}/wild_gki.fragment" common/arch/arm64/configs/wild_gki.fragment
  58. if [[ ${{ inputs.version }} == "android16-6.12" ]]; then
  59. tools/bazel run \
  60. --config=fast \
  61. --config=stamp \
  62. --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
  63. --disk_cache=/home/runner/.cache/bazel \
  64. //common:kernel_aarch64_dist \
  65. -- --destdir=/home/runner/out
  66. else
  67. tools/bazel run \
  68. --config=fast \
  69. --config=stamp \
  70. --defconfig_fragment=//common:arch/arm64/configs/wild_gki.fragment \
  71. --disk_cache=/home/runner/.cache/bazel \
  72. //common:kernel_aarch64_dist \
  73. -- --dist_dir=/home/runner/out
  74. fi
  75. fi
  76. echo "Contents of /home/runner/out"
  77. ls /home/runner/out
  78. - name: 'Gather Build Artifacts'
  79. shell: bash
  80. working-directory: ${{ github.workspace }}
  81. run: |
  82. set -euo pipefail
  83. if [ -f "/home/runner/out/dist/Image" ]; then
  84. echo "Found Image at /home/runner/out/dist/Image"
  85. if [[ ${{ inputs.bypass }} == "true" ]]; then
  86. cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
  87. else
  88. cp "/home/runner/out/dist/Image" "${{ github.workspace }}/AnyKernel3/Image"
  89. fi
  90. exit 0
  91. fi
  92. if [ -f "/home/runner/out/Image" ]; then
  93. echo "Found Image at /home/runner/out/Image"
  94. if [[ ${{ inputs.bypass }} == "true" ]]; then
  95. cp "/home/runner/out/Image" "${{ github.workspace }}/AnyKernel3/Bypass-Image"
  96. else
  97. cp "/home/runner/out/Image" "${{ github.workspace }}/AnyKernel3/Image"
  98. fi
  99. exit 0
  100. fi
  101. exit 1
  102. - name: 'Patch AnyKernel3 for Bypass Hack'
  103. shell: bash
  104. if: ${{ inputs.bypass == 'true' }}
  105. working-directory: ${{ github.workspace }}/AnyKernel3
  106. run: |
  107. set -euo pipefail
  108. cp ${{ github.action_path }}/patches/bypass.patch "${{ github.workspace }}/AnyKernel3/bypass.patch"
  109. patch -p1 < bypass.patch