prepare.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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.set-matrix.outputs.matrix }}
  38. steps:
  39. - name: Checkout Repository
  40. uses: actions/checkout@v5
  41. - name: Read Config and Generate Matrix
  42. id: set-matrix
  43. run: |
  44. echo "Reading config from ${{ inputs.config_file }}"
  45. if [ ! -f "${{ inputs.config_file }}" ]; then
  46. echo "Error: Config file not found: ${{ inputs.config_file }}"
  47. exit 1
  48. fi
  49. # Read the file content
  50. MATRIX_JSON=$(cat "${{ inputs.config_file }}")
  51. # Compact the JSON to a single line to avoid issues
  52. # If jq is not available, we might need another way, but ubuntu-latest usually has it.
  53. if command -v jq &> /dev/null; then
  54. MATRIX_JSON=$(echo "$MATRIX_JSON" | jq -c .)
  55. else
  56. # Fallback for simple minification if jq missing (unlikely on runner)
  57. MATRIX_JSON=$(echo "$MATRIX_JSON" | tr -d '\n' | tr -d ' ')
  58. fi
  59. echo "Matrix content: $MATRIX_JSON"
  60. # Filter the matrix by variant input if not ALL
  61. if [ "${{ inputs.variant }}" != "" ] && [ "${{ inputs.variant }}" != "ALL" ]; then
  62. if command -v jq &> /dev/null; then
  63. MATRIX_JSON=$(echo "$MATRIX_JSON" | jq -c --arg v "${{ inputs.variant }}" '[.[] | select(.variant == $v)]')
  64. else
  65. echo "Warning: jq not found, cannot filter variants."
  66. fi
  67. fi
  68. echo "Matrix content: $MATRIX_JSON"
  69. echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
  70. build:
  71. needs: generate-matrix
  72. strategy:
  73. fail-fast: false
  74. matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
  75. uses: ./.github/workflows/build.yml
  76. with:
  77. kernel_version: ${{ matrix.kernel_version }}
  78. variant: ${{ matrix.variant }}
  79. ksu_commit: ${{ inputs.ksu_commit }}
  80. anykernel_commit: ${{ inputs.anykernel_commit }}
  81. patches_commit: ${{ inputs.patches_commit }}
  82. susfs_commit: ${{ inputs.susfs_commit }}
  83. feature_set: ${{ inputs.feature_set }}
  84. secrets: inherit