prepare.yml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. jobs:
  24. generate-matrix:
  25. runs-on: ubuntu-latest
  26. outputs:
  27. matrix: ${{ steps.final.outputs.matrix }}
  28. steps:
  29. - name: Checkout Repository
  30. uses: actions/checkout@v7
  31. - name: Read Config and Build Final Matrix
  32. id: final
  33. shell: bash
  34. run: |
  35. if [ ! -f "${{ inputs.config_file }}" ]; then
  36. echo "Error: Config file not found: ${{ inputs.config_file }}"
  37. exit 1
  38. fi
  39. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  40. # Build { "include": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }
  41. # Always include Normal, and add any explicit per-item variant from the config.
  42. FINAL=$(jq -cn \
  43. --argjson cfg "$CONFIG_JSON" '
  44. ($cfg.version | split("-")) as $version_parts
  45. | {
  46. include: (
  47. [
  48. $cfg.include[] as $item
  49. | {
  50. version: $cfg.version,
  51. android_version: $version_parts[0],
  52. kernel_version: $version_parts[1],
  53. sublevel: $item.sublevel,
  54. os_patch_level: $item.date,
  55. variant: "Normal"
  56. }
  57. ]
  58. + [
  59. $cfg.include[] as $item
  60. | select($item.variant != null)
  61. | {
  62. version: $cfg.version,
  63. android_version: $version_parts[0],
  64. kernel_version: $version_parts[1],
  65. sublevel: $item.sublevel,
  66. os_patch_level: $item.date,
  67. variant: $item.variant
  68. }
  69. ]
  70. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  71. )
  72. }')
  73. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  74. build:
  75. needs: generate-matrix
  76. strategy:
  77. fail-fast: false
  78. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  79. uses: ./.github/workflows/build.yml
  80. with:
  81. version: ${{ matrix.version }}
  82. android_version: ${{ matrix.android_version }}
  83. kernel_version: ${{ matrix.kernel_version }}
  84. sublevel: ${{ matrix.sublevel }}
  85. os_patch_level: ${{ matrix.os_patch_level }}
  86. variant: ${{ matrix.variant }}
  87. feature_set: ${{ inputs.feature_set }}
  88. ksu_branch: ${{ inputs.ksu_branch }}
  89. susfs_commit: ${{ inputs.susfs_commit }}
  90. secrets: inherit