Dependencies between build matrix jobs?

I have the following job

Build:
    runs-on: ubuntu-latest

    strategy:
      matrix:
        package:
          - name: ogg
            working-dir: ogg
            cmake-options: >
              -DCMAKE_BUILD_TYPE=Release
              -DCMAKE_INSTALL_PREFIX=/usr
              -DBUILD_SHARED_LIBS=ON

          - name: flac
            working-dir: flac
            cmake-options: >
              -DCMAKE_BUILD_TYPE=Release
              -DCMAKE_INSTALL_PREFIX=/usr
              -DBUILD_SHARED_LIBS=ON

    steps:
      - name: Checkout repo and submodules
        uses: actions/checkout@v2
        with:
          submodules: recursive

      - name: Configure
        working-directory: ${{ matrix.package.working-dir }}
        run: cmake -S . -B cmake-build ${{ matrix.package.cmake-options }}

      - name: Build
        working-directory: ${{ matrix.package.working-dir }}
        run: cmake --build cmake-build -- -j$(expr $(nproc) + 2)

      - name: Install
        working-directory: ${{ matrix.package.working-dir }}
        run: DESTDIR=cmake-install cmake --install cmake-build

      - name: Package
        working-directory: ${{ matrix.package.working-dir }}/cmake-install
        run: tar cvf - * | xz -ce9 >> ${{ matrix.package.name }}.tar.xz

      - uses: actions/upload-artifact@master
        with:
          name: ${{ matrix.package.name }}.tar.xz
          path: ${{ matrix.package.working-dir }}/cmake-install/${{ matrix.package.name }}.tar.xz

flac depends on ogg and won’t build without it being installed, so what i’m trying to achieve is:

  • Build ogg
  • Upload build output as an artifact

When building flac

  • Download ogg’s artifact
  • Unpack on /
  • Proceed with the build

This works without the matrix stuff, i.e with manual setup. but it requires a lot of copy-pasting!

But i’m struggling to achieve this in the above example.

How do i say matrix.package.flac needs matrix.package.ogg?

A side note: there will be more packages in the matrix, but this will suffice for the demo.