name: Prepare and Build on: workflow_call: inputs: config_file: description: "Path to the JSON config file" required: true type: string feature_set: description: "Feature Set" required: false type: string variant: description: "Build Variant (All, Normal, Bypass, Wild)" required: false type: string use_repo: description: "Use repo for downloading kernel source" required: false type: boolean default: false jobs: generate-matrix: runs-on: ubuntu-latest outputs: matrix: ${{ steps.final.outputs.matrix }} steps: - name: Checkout Repository uses: actions/checkout@v5 - name: Read Config and Build Final Matrix id: final shell: bash run: | if [ ! -f "${{ inputs.config_file }}" ]; then echo "Error: Config file not found: ${{ inputs.config_file }}" exit 1 fi CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .) # Build the variant list as a JSON array if [ "${{ inputs.variant }}" = "All" ] || [ -z "${{ inputs.variant }}" ]; then VARIANTS='["Normal","Bypass","Wild"]' else VARIANTS=$(jq -cn --arg v "${{ inputs.variant }}" '[$v]') fi # Build { "include": [ {kernel_version:..., variant: ...}, ... ] } FINAL=$(jq -cn \ --argjson cfg "$CONFIG_JSON" \ --argjson variants "$VARIANTS" ' def dedup($items): reduce $items[] as $item ([]; if any(.[]; . == $item) then . else . + [$item] end); ($cfg.version | split("-")) as $version_parts | { include: ( [ $cfg.include[] as $item | $variants[] as $build_variant | { android_version: $version_parts[0], kernel_version: $version_parts[1], sublevel: $item.sublevel, os_patch_level: $item.date, variant: $build_variant } ] + [ $cfg.include[] | select(.variant != null) | { android_version: $version_parts[0], kernel_version: $version_parts[1], sublevel: .sublevel, os_patch_level: .date, variant: "Normal", config_variant: .variant } ] ) }') echo "matrix=$FINAL" >> "$GITHUB_OUTPUT" build: needs: generate-matrix strategy: fail-fast: false matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} uses: ./.github/workflows/build.yml with: android_version: ${{ matrix.android_version }} kernel_version: ${{ matrix.kernel_version }} sublevel: ${{ matrix.sublevel }} os_patch_level: ${{ matrix.os_patch_level }} variant: ${{ matrix.variant }} config_variant: ${{ matrix.config_variant || '' }} feature_set: ${{ inputs.feature_set }} use_repo: ${{ inputs.use_repo }} secrets: inherit