prepare.yml 3.0 KB

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