OS Specific build steps

I need to build my application on Linux and macOS. I need to do some setup up stuff before I run and the setup is different for each OS.  How can I specify the OS-dependent setup**?**

This is what I have so far. I get bogged down because I can’t apt-get in macOS.

jobs:
  build:
    runs-on: ${{matrix.os}}
    strategy:
      matrix:
        os: [ubuntu-18.04, macOS]
    steps:
    - name: Install gfortran
      run: sudo apt-get install gfortran
    - uses: actions/checkout@v2
    - name: mkdir bin
      run: mkdir bin
    - name: cmake
      run: cmake ..
      working-directory: ./bin
    - name: make
      run: make -j
      working-directory: ./bin
    - name: ctest
      run: ctest -j
      working-directory: ./bin
1 Like

@jlconlin ,

On macOS , Xcode contains the tools needed to compile native code on the machine, include gfortran. So you do not need to additionally install gfortran  for macOS , and just install gfortran for Linux.

For example:

jobs:
  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    steps:
      - name: Install gfortran for Linux
        if: matrix.os == 'ubuntu-latest'
        run: sudo apt-get install gfortran

      - name: Check gfortran version
        run: gfortran --version
3 Likes