# build.yml
# Reusable workflow that builds Libation for all platforms.
---
name: build

on:
  workflow_call:
    inputs:
      libation-version:
        type: string
        description: "Libation version number"
        required: true
      dotnet-version:
        type: string
        default: "10.x"
        description: ".NET version to target"
      run-unit-tests:
        type: boolean
        description: "Whether to run unit tests prior to publishing."
      publish-r2r:
        type: boolean
        description: "Whether to publish assemblies as ReadyToRun."
      release:
        type: boolean
        description: "Whether this workflow is being called as a release"
      retention-days:
        type: number
        description: "Number of days the artifacts are to be retained."

jobs:    
  windows:
    uses: ./.github/workflows/build-windows.yml
    with:
      libation-version: ${{ inputs.libation-version }}
      dotnet-version: ${{ inputs.dotnet-version }}
      run-unit-tests: ${{ inputs.run-unit-tests }}
      publish-r2r: ${{ inputs.publish-r2r }}
      retention-days: ${{ inputs.retention-days }}
      
  macOS:
    strategy:
      matrix:
        architecture: [x64, arm64]
    uses: ./.github/workflows/build-mac.yml
    with:
      libation-version: ${{ inputs.libation-version }}
      dotnet-version: ${{ inputs.dotnet-version }}
      run-unit-tests: ${{ inputs.run-unit-tests }}
      publish-r2r: ${{ inputs.publish-r2r }}
      retention-days: ${{ inputs.retention-days }}
      architecture: ${{ matrix.architecture }}
      sign-app: ${{ inputs.release || vars.SIGN_MAC_APP_ON_VALIDATE == 'true' }}
    secrets: inherit

  linux:
    strategy:
      matrix:
        OS: [Redhat, Debian]
        architecture: [x64, arm64]
    uses: ./.github/workflows/build-linux.yml
    with:
      libation-version: ${{ inputs.libation-version }}
      dotnet-version: ${{ inputs.dotnet-version }}
      run-unit-tests: ${{ inputs.run-unit-tests }}
      publish-r2r: ${{ inputs.publish-r2r }}
      retention-days: ${{ inputs.retention-days }}
      architecture: ${{ matrix.architecture }}
      OS: ${{ matrix.OS }}

