GithubActions on Windows host: how to run many lines which makes whole step abort when one fails?

I had this step in a macOS lane:

jobs:
  macOS_build:
    runs-on: macOS-latest
    steps:
    - uses: actions/[email protected]
    - name: Build in DEBUG and RELEASE mode
      run: ./configure.sh && make DEBUG && make RELEASE

Then I successfully split it up this way:

jobs:
  macOS_build:
    runs-on: macOS-latest
    steps:
    - name: Build in DEBUG and RELEASE mode
      run: |
        ./configure.sh
        make DEBUG
        make RELEASE

This conversion works because if make DEBUG fails, make RELEASE won’t be executed and the whole step is marked as FAILED by GitHubActions.

However, trying to convert this from the Windows lane:

jobs:
  windows_build:
    runs-on: windows-latest
    steps:
    - uses: actions/[email protected]
    - name: Build in DEBUG and RELEASE mode
      shell: cmd
      run: configure.bat && make.bat DEBUG && make.bat RELEASE

To this:

jobs:
  windows_build:
    runs-on: windows-latest
    steps:
    - uses: actions/[email protected]
    - name: Build in DEBUG and RELEASE mode
      shell: cmd
      run: |
        configure.bat
        make.bat DEBUG
        make.bat RELEASE

Doesn’t work, because strangely enough, only the first line is executed. So I tried trying to change the shell attribute to powershell:

jobs:
  windows_build:
    runs-on: windows-latest
    steps:
    - uses: actions/[email protected]
    - name: Build in DEBUG and RELEASE mode
      shell: powershell
      run: |
        configure.bat
        make.bat DEBUG
        make.bat RELEASE

However this fails with:

configure.bat : The term ‘configure.bat’ is not recognized as the name
of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path
is correct and try again.

Then I saw this other SO answer, so I converted it to:

jobs:
  windows_build:
    runs-on: windows-latest
    steps:
    - uses: actions/[email protected]
    - name: Build in DEBUG and RELEASE mode
      shell: powershell
      run: |
        & .configure.bat
        & .make.bat DEBUG
        & .make.bat RELEASE

This finally launches all batch files independently, however it seems to ignore the exit code (so if configure.bat fails, it still runs the next lines).

Any idea how to separate lines in a GithubActions workflow properly?

Source: Windows Questions

LEAVE A COMMENT