prepare.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. name: Prepare and Build
  2. on:
  3. workflow_call:
  4. inputs:
  5. config_file:
  6. description: "Path to the JSON config file"
  7. required: true
  8. type: string
  9. feature_set:
  10. description: "Feature Set"
  11. required: false
  12. type: string
  13. ksu_branch:
  14. description: "KernelSU branch or commit (empty = latest dev)"
  15. required: false
  16. type: string
  17. default: ""
  18. susfs_commit:
  19. description: "SUSFS commit hash (empty = latest on auto-derived branch)"
  20. required: false
  21. type: string
  22. default: ""
  23. root_flavor:
  24. description: "Mutually exclusive root implementation (classic, next, or resukisu)"
  25. required: false
  26. type: string
  27. default: ""
  28. root_commit:
  29. description: "Exact root implementation commit"
  30. required: false
  31. type: string
  32. default: ""
  33. nomount_commit:
  34. description: "Exact NoMount commit"
  35. required: false
  36. type: string
  37. default: ""
  38. kernel_patches_commit:
  39. description: "Exact kernel_patches commit (resolved automatically)"
  40. required: false
  41. type: string
  42. default: ""
  43. anykernel3_commit:
  44. description: "Exact AnyKernel3 commit (resolved automatically)"
  45. required: false
  46. type: string
  47. default: ""
  48. droidspaces_commit:
  49. description: "Exact Droidspaces-OSS commit (resolved automatically)"
  50. required: false
  51. type: string
  52. default: ""
  53. brand_name:
  54. description: "Kernel branding text appended to the version string"
  55. required: false
  56. type: string
  57. default: Wild
  58. preserve_abi:
  59. description: "Keep ABI/KMI protection files intact and verify their hashes"
  60. required: false
  61. type: boolean
  62. default: false
  63. build_bypass:
  64. description: "Produce the legacy bypass image"
  65. required: false
  66. type: boolean
  67. default: true
  68. os_patch_level:
  69. description: "Optional filter: patch date (YYYY-MM), kernel sublevel, lts (LTS branch), or all"
  70. required: false
  71. type: string
  72. default: ""
  73. variant:
  74. description: "Artifact variant label"
  75. required: false
  76. type: string
  77. default: ""
  78. jobs:
  79. generate-matrix:
  80. runs-on: ubuntu-latest
  81. outputs:
  82. matrix: ${{ steps.final.outputs.matrix }}
  83. steps:
  84. - name: Checkout Repository
  85. uses: actions/checkout@v7
  86. - name: Read Config and Build Final Matrix
  87. id: final
  88. shell: bash
  89. run: |
  90. if [ ! -f "${{ inputs.config_file }}" ]; then
  91. echo "Error: Config file not found: ${{ inputs.config_file }}"
  92. exit 1
  93. fi
  94. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  95. # Build { "include": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }.
  96. # An explicit patch-level filter keeps manual validation dispatches bounded.
  97. FINAL=$(jq -cn \
  98. --argjson cfg "$CONFIG_JSON" \
  99. --arg requested_variant "${{ inputs.variant }}" '
  100. ($cfg.version | split("-")) as $version_parts
  101. | ($cfg.include) as $targets
  102. | {
  103. include: (
  104. [
  105. $targets[] as $item
  106. | {
  107. version: $cfg.version,
  108. android_version: $version_parts[0],
  109. kernel_version: $version_parts[1],
  110. sublevel: $item.sublevel,
  111. os_patch_level: $item.date,
  112. variant: (if $requested_variant == "" then "Normal" else $requested_variant end)
  113. }
  114. ]
  115. + (if $requested_variant == "" then [
  116. $targets[] as $item
  117. | select($item.variant != null)
  118. | {
  119. version: $cfg.version,
  120. android_version: $version_parts[0],
  121. kernel_version: $version_parts[1],
  122. sublevel: $item.sublevel,
  123. os_patch_level: $item.date,
  124. variant: $item.variant
  125. }
  126. ] else [] end)
  127. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  128. )
  129. }')
  130. SELECTED_PATCH_LEVEL="${{ inputs.os_patch_level }}"
  131. if [ "$SELECTED_PATCH_LEVEL" = "all" ]; then
  132. SELECTED_PATCH_LEVEL=""
  133. fi
  134. if [ -n "$SELECTED_PATCH_LEVEL" ]; then
  135. FULL_FINAL="$FINAL"
  136. FINAL=$(jq -c --arg patch_level "$SELECTED_PATCH_LEVEL" '
  137. {include: [.include[] | select(.os_patch_level == $patch_level)]}
  138. ' <<< "$FINAL")
  139. # No date matched -- try interpreting the value as a kernel sublevel
  140. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  141. FINAL=$(jq -c --arg sublevel "$SELECTED_PATCH_LEVEL" '
  142. {include: [.include[] | select(.sublevel == $sublevel)]}
  143. ' <<< "$FULL_FINAL")
  144. fi
  145. fi
  146. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  147. echo "Error: no build targets match patch level '${SELECTED_PATCH_LEVEL}'." >&2
  148. exit 1
  149. fi
  150. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  151. build:
  152. needs: generate-matrix
  153. strategy:
  154. fail-fast: false
  155. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  156. uses: ./.github/workflows/build.yml
  157. with:
  158. version: ${{ matrix.version }}
  159. android_version: ${{ matrix.android_version }}
  160. kernel_version: ${{ matrix.kernel_version }}
  161. sublevel: ${{ matrix.sublevel }}
  162. os_patch_level: ${{ matrix.os_patch_level }}
  163. variant: ${{ matrix.variant }}
  164. feature_set: ${{ inputs.feature_set }}
  165. ksu_branch: ${{ inputs.ksu_branch }}
  166. susfs_commit: ${{ inputs.susfs_commit }}
  167. root_flavor: ${{ inputs.root_flavor }}
  168. root_commit: ${{ inputs.root_commit }}
  169. nomount_commit: ${{ inputs.nomount_commit }}
  170. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  171. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  172. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  173. brand_name: ${{ inputs.brand_name }}
  174. preserve_abi: ${{ inputs.preserve_abi }}
  175. build_bypass: ${{ inputs.build_bypass }}
  176. secrets: inherit