prepare.yml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 (kernelsu, 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. bypass:
  59. description: "Apply the kernel version-check bypass hack (disabled by default)"
  60. required: false
  61. type: boolean
  62. default: false
  63. use_cache:
  64. description: "Enable ccache/bazel cache"
  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. env:
  90. INPUT_OS_PATCH_LEVEL: ${{ inputs.os_patch_level }}
  91. run: |
  92. if [ ! -f "${{ inputs.config_file }}" ]; then
  93. echo "Error: Config file not found: ${{ inputs.config_file }}"
  94. exit 1
  95. fi
  96. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  97. # Build { "include": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }.
  98. # An explicit patch-level filter keeps manual validation dispatches bounded.
  99. FINAL=$(jq -cn \
  100. --argjson cfg "$CONFIG_JSON" \
  101. --arg requested_variant "${{ inputs.variant }}" '
  102. ($cfg.version | split("-")) as $version_parts
  103. | ($cfg.include) as $targets
  104. | {
  105. include: (
  106. [
  107. $targets[] as $item
  108. | {
  109. version: $cfg.version,
  110. android_version: $version_parts[0],
  111. kernel_version: $version_parts[1],
  112. sublevel: $item.sublevel,
  113. os_patch_level: $item.date,
  114. variant: (if $requested_variant == "" then "Normal" else $requested_variant end)
  115. }
  116. ]
  117. + (if $requested_variant == "" then [
  118. $targets[] as $item
  119. | select($item.variant != null)
  120. | {
  121. version: $cfg.version,
  122. android_version: $version_parts[0],
  123. kernel_version: $version_parts[1],
  124. sublevel: $item.sublevel,
  125. os_patch_level: $item.date,
  126. variant: $item.variant
  127. }
  128. ] else [] end)
  129. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  130. )
  131. }')
  132. SELECTED_PATCH_LEVEL="$(printf '%s' "$INPUT_OS_PATCH_LEVEL" | tr '[:upper:]' '[:lower:]')"
  133. if [ "$SELECTED_PATCH_LEVEL" = "all" ]; then
  134. SELECTED_PATCH_LEVEL=""
  135. fi
  136. if [ -n "$SELECTED_PATCH_LEVEL" ]; then
  137. FULL_FINAL="$FINAL"
  138. FINAL=$(jq -c --arg patch_level "$SELECTED_PATCH_LEVEL" '
  139. {include: [.include[] | select(.os_patch_level == $patch_level)]}
  140. ' <<< "$FINAL")
  141. # No date matched -- try interpreting the value as a kernel sublevel
  142. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  143. FINAL=$(jq -c --arg sublevel "$SELECTED_PATCH_LEVEL" '
  144. {include: [.include[] | select(.sublevel == $sublevel)]}
  145. ' <<< "$FULL_FINAL")
  146. fi
  147. fi
  148. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  149. echo "Error: no build targets match patch level '${SELECTED_PATCH_LEVEL}'." >&2
  150. exit 1
  151. fi
  152. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  153. build:
  154. needs: generate-matrix
  155. strategy:
  156. fail-fast: false
  157. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  158. uses: ./.github/workflows/build.yml
  159. with:
  160. version: ${{ matrix.version }}
  161. android_version: ${{ matrix.android_version }}
  162. kernel_version: ${{ matrix.kernel_version }}
  163. sublevel: ${{ matrix.sublevel }}
  164. os_patch_level: ${{ matrix.os_patch_level }}
  165. variant: ${{ matrix.variant }}
  166. feature_set: ${{ inputs.feature_set }}
  167. ksu_branch: ${{ inputs.ksu_branch }}
  168. susfs_commit: ${{ inputs.susfs_commit }}
  169. root_flavor: ${{ inputs.root_flavor }}
  170. root_commit: ${{ inputs.root_commit }}
  171. nomount_commit: ${{ inputs.nomount_commit }}
  172. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  173. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  174. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  175. brand_name: ${{ inputs.brand_name }}
  176. bypass: ${{ inputs.bypass }}
  177. use_cache: ${{ inputs.use_cache }}
  178. secrets: inherit