name: Generate strategy matrix

on:
  workflow_call:
    inputs:
      os:
        description: 'The operating system to use for the build ("linux", "macos", "windows").'
        required: false
        type: string
      strategy_matrix:
        # TODO: Support additional strategies, e.g. "ubuntu" for generating all Ubuntu configurations.
        description: 'The strategy matrix to use for generating the configurations ("minimal", "all").'
        required: false
        type: string
        default: "minimal"
    outputs:
      matrix:
        description: "The generated strategy matrix."
        value: ${{ jobs.generate-matrix.outputs.matrix }}

jobs:
  generate-matrix:
    runs-on: ubuntu-latest
    outputs:
      matrix: ${{ steps.generate.outputs.matrix }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0

      - name: Set up Python
        uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
        with:
          python-version: 3.13

      - name: Generate strategy matrix
        working-directory: .github/scripts/strategy-matrix
        id: generate
        env:
          GENERATE_CONFIG: ${{ inputs.os != '' && format('--config={0}.json', inputs.os) || '' }}
          GENERATE_OPTION: ${{ inputs.strategy_matrix == 'all' && '--all' || '' }}
        run: ./generate.py ${GENERATE_OPTION} ${GENERATE_CONFIG} >> "${GITHUB_OUTPUT}"
