prepare.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. ksu_commit:
  10. description: "KSU Commit"
  11. required: false
  12. type: string
  13. anykernel_commit:
  14. description: "AnyKernel3 Commit"
  15. required: false
  16. type: string
  17. patches_commit:
  18. description: "Kernel Patches Commit"
  19. required: false
  20. type: string
  21. susfs_commit:
  22. description: "SUSFS Commit"
  23. required: false
  24. type: string
  25. feature_set:
  26. description: "Feature Set"
  27. required: false
  28. type: string
  29. variant:
  30. description: "Build Variant (All, Normal, Bypass, Wild)"
  31. required: false
  32. type: string
  33. jobs:
  34. generate-matrix:
  35. runs-on: ubuntu-latest
  36. outputs:
  37. matrix: ${{ steps.final.outputs.matrix }}
  38. steps:
  39. - name: Checkout Repository
  40. uses: actions/checkout@v5
  41. - name: Read Config and Build Final Matrix
  42. id: final
  43. shell: bash
  44. run: |
  45. if [ ! -f "${{ inputs.config_file }}" ]; then
  46. echo "Error: Config file not found: ${{ inputs.config_file }}"
  47. exit 1
  48. fi
  49. CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
  50. # Build the variant list as a JSON array
  51. if [ "${{ inputs.variant }}" = "All" ] || [ -z "${{ inputs.variant }}" ]; then
  52. VARIANTS='["Normal","Bypass","Wild"]'
  53. else
  54. VARIANTS=$(jq -cn --arg v "${{ inputs.variant }}" '[$v]')
  55. fi
  56. # Build { "include": [ {kernel_version:..., variant: ...}, ... ] }
  57. FINAL=$(jq -cn \
  58. --argjson cfg "$CONFIG_JSON" \
  59. --argjson variants "$VARIANTS" '
  60. {
  61. include: [
  62. $cfg.include[] as $item
  63. | $variants[] as $variant
  64. | $item + {variant: $variant}
  65. ]
  66. }')
  67. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  68. build:
  69. needs: generate-matrix
  70. strategy:
  71. fail-fast: false
  72. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  73. uses: ./.github/workflows/build.yml
  74. with:
  75. kernel_version: ${{ matrix.kernel_version }}
  76. variant: ${{ matrix.variant }}
  77. ksu_commit: ${{ inputs.ksu_commit }}
  78. anykernel_commit: ${{ inputs.anykernel_commit }}
  79. patches_commit: ${{ inputs.patches_commit }}
  80. susfs_commit: ${{ inputs.susfs_commit }}
  81. feature_set: ${{ inputs.feature_set }}
  82. secrets: inherit