# Test building the quarto-latexmk command
on:
  workflow_dispatch:
  push:
    branches: main
  pull_request:
    branches: main
name: Test quarto-latexmk

jobs:
  quarto-latexmk:
    runs-on: ${{ matrix.config.os }}

    name: ${{ matrix.config.os }}

    strategy:
      fail-fast: false
      matrix:
        config:
          - { os: windows-latest }
          - { os: macOS-latest }
          - { os: ubuntu-latest }

    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Configure Quarto
        uses: ./.github/workflows/actions/quarto-dev

      - name: Test Windows
        if: runner.os == 'Windows'
        run: |
          cd package/src
          .\quarto-bld.cmd compile-quarto-latexmk --target x86_64-pc-windows-msvc --name tinitex
          tree ..\dist\bin /f /a
          cd ..\dist\bin\tinitex\x86_64-pc-windows-msvc
          .\tinitex.exe --help

      - name: Test macOS
        if: runner.os == 'macOS'
        run: |
          cd package/src
          ./quarto-bld compile-quarto-latexmk --target aarch64-apple-darwin --name tinitex
          ls -R ../dist/bin
          ../dist/bin/tinitex/aarch64-apple-darwin/tinitex --help

      - name: Test Linux
        if: runner.os == 'Linux'
        run: |
          cd package/src
          ./quarto-bld compile-quarto-latexmk --target x86_64-unknown-linux-gnu --name tinitex
          ls -R ../dist/bin
          ../dist/bin/tinitex/x86_64-unknown-linux-gnu/tinitex --help

      - name: Upload binary
        uses: actions/upload-artifact@v7
        with:
          name: tinitex-${{ matrix.config.os }}
          path: |
            package/dist/bin/tinitex/*/tinitex*
