prepare.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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. os_patch_level:
  64. description: "Optional filter: patch date (YYYY-MM), kernel sublevel, lts (LTS branch), or all"
  65. required: false
  66. type: string
  67. default: ""
  68. variant:
  69. description: "Artifact variant label"
  70. required: false
  71. type: string
  72. default: ""
  73. jobs:
  74. generate-matrix:
  75. runs-on: ubuntu-latest
  76. outputs:
  77. matrix: ${{ steps.final.outputs.matrix }}
  78. steps:
  79. - name: Checkout Repository
  80. uses: actions/checkout@v7
  81. - name: Read Config and Build Final Matrix
  82. id: final
  83. shell: bash
  84. run: |
  85. if [ ! -f "${{ inputs.config_file }}" ]; then
  86. echo "Error: Config file not found: ${{ inputs.config_file }}"
  87. exit 1
  88. fi
  89. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  90. # Build { "include": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }.
  91. # An explicit patch-level filter keeps manual validation dispatches bounded.
  92. FINAL=$(jq -cn \
  93. --argjson cfg "$CONFIG_JSON" \
  94. --arg requested_variant "${{ inputs.variant }}" '
  95. ($cfg.version | split("-")) as $version_parts
  96. | ($cfg.include) as $targets
  97. | {
  98. include: (
  99. [
  100. $targets[] as $item
  101. | {
  102. version: $cfg.version,
  103. android_version: $version_parts[0],
  104. kernel_version: $version_parts[1],
  105. sublevel: $item.sublevel,
  106. os_patch_level: $item.date,
  107. variant: (if $requested_variant == "" then "Normal" else $requested_variant end)
  108. }
  109. ]
  110. + (if $requested_variant == "" then [
  111. $targets[] as $item
  112. | select($item.variant != null)
  113. | {
  114. version: $cfg.version,
  115. android_version: $version_parts[0],
  116. kernel_version: $version_parts[1],
  117. sublevel: $item.sublevel,
  118. os_patch_level: $item.date,
  119. variant: $item.variant
  120. }
  121. ] else [] end)
  122. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  123. )
  124. }')
  125. SELECTED_PATCH_LEVEL="${{ inputs.os_patch_level }}"
  126. if [ "$(printf '%s' "$SELECTED_PATCH_LEVEL" | tr '[:upper:]' '[:lower:]')" = "all" ]; then
  127. SELECTED_PATCH_LEVEL=""
  128. fi
  129. if [ -n "$SELECTED_PATCH_LEVEL" ]; then
  130. FULL_FINAL="$FINAL"
  131. FINAL=$(jq -c --arg patch_level "$SELECTED_PATCH_LEVEL" '
  132. {include: [.include[] | select(.os_patch_level == $patch_level)]}
  133. ' <<< "$FINAL")
  134. # No date matched -- try interpreting the value as a kernel sublevel
  135. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  136. FINAL=$(jq -c --arg sublevel "$SELECTED_PATCH_LEVEL" '
  137. {include: [.include[] | select(.sublevel == $sublevel)]}
  138. ' <<< "$FULL_FINAL")
  139. fi
  140. fi
  141. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  142. echo "Error: no build targets match patch level '${SELECTED_PATCH_LEVEL}'." >&2
  143. exit 1
  144. fi
  145. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  146. build:
  147. needs: generate-matrix
  148. strategy:
  149. fail-fast: false
  150. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  151. uses: ./.github/workflows/build.yml
  152. with:
  153. version: ${{ matrix.version }}
  154. android_version: ${{ matrix.android_version }}
  155. kernel_version: ${{ matrix.kernel_version }}
  156. sublevel: ${{ matrix.sublevel }}
  157. os_patch_level: ${{ matrix.os_patch_level }}
  158. variant: ${{ matrix.variant }}
  159. feature_set: ${{ inputs.feature_set }}
  160. ksu_branch: ${{ inputs.ksu_branch }}
  161. susfs_commit: ${{ inputs.susfs_commit }}
  162. root_flavor: ${{ inputs.root_flavor }}
  163. root_commit: ${{ inputs.root_commit }}
  164. nomount_commit: ${{ inputs.nomount_commit }}
  165. kernel_patches_commit: ${{ inputs.kernel_patches_commit }}
  166. anykernel3_commit: ${{ inputs.anykernel3_commit }}
  167. droidspaces_commit: ${{ inputs.droidspaces_commit }}
  168. brand_name: ${{ inputs.brand_name }}
  169. bypass: ${{ inputs.bypass }}
  170. secrets: inherit