prepare.yml 3.3 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": [ {android_version:..., kernel_version:..., sublevel:..., os_patch_level:..., variant: ...}, ... ] }
  46. FINAL=$(jq -cn \
  47. --argjson cfg "$CONFIG_JSON" \
  48. --argjson variants "$VARIANTS" '
  49. ($cfg.version | split("-")) as $version_parts
  50. | {
  51. include: (
  52. [
  53. $cfg.include[] as $item
  54. | $variants[] as $build_variant
  55. | {
  56. version: $cfg.version,
  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[] as $item
  66. | select($item.variant != null)
  67. | {
  68. version: $cfg.version,
  69. android_version: $version_parts[0],
  70. kernel_version: $version_parts[1],
  71. sublevel: $item.sublevel,
  72. os_patch_level: $item.date,
  73. variant: $item.variant
  74. }
  75. ]
  76. | unique_by([.android_version, .kernel_version, .sublevel, .os_patch_level, .variant])
  77. )
  78. }')
  79. echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
  80. build:
  81. needs: generate-matrix
  82. strategy:
  83. fail-fast: false
  84. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  85. uses: ./.github/workflows/build.yml
  86. with:
  87. version: ${{ matrix.version }}
  88. android_version: ${{ matrix.android_version }}
  89. kernel_version: ${{ matrix.kernel_version }}
  90. sublevel: ${{ matrix.sublevel }}
  91. os_patch_level: ${{ matrix.os_patch_level }}
  92. variant: ${{ matrix.variant }}
  93. feature_set: ${{ inputs.feature_set }}
  94. use_repo: ${{ inputs.use_repo }}
  95. secrets: inherit