prepare.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. preserve_abi:
  39. description: "Keep ABI/KMI protection files intact and verify their hashes"
  40. required: false
  41. type: boolean
  42. default: false
  43. build_bypass:
  44. description: "Produce the legacy bypass image"
  45. required: false
  46. type: boolean
  47. default: true
  48. os_patch_level:
  49. description: "Optional filter: patch date (YYYY-MM), kernel sublevel, lts (LTS branch), or all"
  50. required: false
  51. type: string
  52. default: ""
  53. variant:
  54. description: "Artifact variant label"
  55. required: false
  56. type: string
  57. default: ""
  58. jobs:
  59. generate-matrix:
  60. runs-on: ubuntu-latest
  61. outputs:
  62. matrix: ${{ steps.final.outputs.matrix }}
  63. steps:
  64. - name: Checkout Repository
  65. uses: actions/checkout@v7
  66. - name: Read Config and Build Final Matrix
  67. id: final
  68. shell: bash
  69. run: |
  70. if [ ! -f "${{ inputs.config_file }}" ]; then
  71. echo "Error: Config file not found: ${{ inputs.config_file }}"
  72. exit 1
  73. fi
  74. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  75. # Build { "include": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }.
  76. # An explicit patch-level filter keeps manual validation dispatches bounded.
  77. FINAL=$(jq -cn \
  78. --argjson cfg "$CONFIG_JSON" \
  79. --arg requested_variant "${{ inputs.variant }}" '
  80. ($cfg.version | split("-")) as $version_parts
  81. | ($cfg.include) as $targets
  82. | {
  83. include: (
  84. [
  85. $targets[] as $item
  86. | {
  87. version: $cfg.version,
  88. android_version: $version_parts[0],
  89. kernel_version: $version_parts[1],
  90. sublevel: $item.sublevel,
  91. os_patch_level: $item.date,
  92. variant: (if $requested_variant == "" then "Normal" else $requested_variant end)
  93. }
  94. ]
  95. + (if $requested_variant == "" then [
  96. $targets[] as $item
  97. | select($item.variant != null)
  98. | {
  99. version: $cfg.version,
  100. android_version: $version_parts[0],
  101. kernel_version: $version_parts[1],
  102. sublevel: $item.sublevel,
  103. os_patch_level: $item.date,
  104. variant: $item.variant
  105. }
  106. ] else [] end)
  107. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  108. )
  109. }')
  110. SELECTED_PATCH_LEVEL="${{ inputs.os_patch_level }}"
  111. if [ "$SELECTED_PATCH_LEVEL" = "all" ]; then
  112. SELECTED_PATCH_LEVEL=""
  113. fi
  114. if [ -n "$SELECTED_PATCH_LEVEL" ]; then
  115. FULL_FINAL="$FINAL"
  116. FINAL=$(jq -c --arg patch_level "$SELECTED_PATCH_LEVEL" '
  117. {include: [.include[] | select(.os_patch_level == $patch_level)]}
  118. ' <<< "$FINAL")
  119. # No date matched -- try interpreting the value as a kernel sublevel
  120. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  121. FINAL=$(jq -c --arg sublevel "$SELECTED_PATCH_LEVEL" '
  122. {include: [.include[] | select(.sublevel == $sublevel)]}
  123. ' <<< "$FULL_FINAL")
  124. fi
  125. fi
  126. if [ "$(jq '.include | length' <<< "$FINAL")" -eq 0 ]; then
  127. echo "Error: no build targets match patch level '${SELECTED_PATCH_LEVEL}'." >&2
  128. exit 1
  129. fi
  130. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  131. build:
  132. needs: generate-matrix
  133. strategy:
  134. fail-fast: false
  135. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  136. uses: ./.github/workflows/build.yml
  137. with:
  138. version: ${{ matrix.version }}
  139. android_version: ${{ matrix.android_version }}
  140. kernel_version: ${{ matrix.kernel_version }}
  141. sublevel: ${{ matrix.sublevel }}
  142. os_patch_level: ${{ matrix.os_patch_level }}
  143. variant: ${{ matrix.variant }}
  144. feature_set: ${{ inputs.feature_set }}
  145. ksu_branch: ${{ inputs.ksu_branch }}
  146. susfs_commit: ${{ inputs.susfs_commit }}
  147. root_flavor: ${{ inputs.root_flavor }}
  148. root_commit: ${{ inputs.root_commit }}
  149. nomount_commit: ${{ inputs.nomount_commit }}
  150. preserve_abi: ${{ inputs.preserve_abi }}
  151. build_bypass: ${{ inputs.build_bypass }}
  152. secrets: inherit