prepare.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. def dedup($items): reduce $items[] as $item ([]; if any(.[]; . == $item) then . else . + [$item] end);
  50. ($cfg.version | split("-")) as $version_parts
  51. | {
  52. include: (
  53. [
  54. $cfg.include[] as $item
  55. | $variants[] as $build_variant
  56. | {
  57. android_version: $version_parts[0],
  58. kernel_version: $version_parts[1],
  59. sublevel: $item.sublevel,
  60. os_patch_level: $item.date,
  61. variant: $build_variant
  62. }
  63. ]
  64. + [
  65. $cfg.include[]
  66. | select(.variant != null)
  67. | {
  68. android_version: $version_parts[0],
  69. kernel_version: $version_parts[1],
  70. sublevel: .sublevel,
  71. os_patch_level: .date,
  72. variant: "Normal",
  73. config_variant: .variant
  74. }
  75. ]
  76. )
  77. }')
  78. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  79. build:
  80. needs: generate-matrix
  81. strategy:
  82. fail-fast: false
  83. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  84. uses: ./.github/workflows/build.yml
  85. with:
  86. android_version: ${{ matrix.android_version }}
  87. kernel_version: ${{ matrix.kernel_version }}
  88. sublevel: ${{ matrix.sublevel }}
  89. os_patch_level: ${{ matrix.os_patch_level }}
  90. variant: ${{ matrix.variant }}
  91. config_variant: ${{ matrix.config_variant || '' }}
  92. feature_set: ${{ inputs.feature_set }}
  93. use_repo: ${{ inputs.use_repo }}
  94. secrets: inherit