prepare.yml 2.1 KB

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