Home > Blockchain >  Github actions/upload-artifact@v2 breaks with windows-latest
Github actions/upload-artifact@v2 breaks with windows-latest

Time:02-25

I have the following GitHub actions workflow for a C# (.net 6) project that works fine with ubuntu-latest. But for some reason we need it to use windows-latest, it breaks with the error (the error after yaml workflow).

Yaml workflow:

jobs:
  build:
    name: Create Release
    runs-on: windows-latest

    steps:
    - name: Setup Checkout
      uses: actions/checkout@v2
    - name: Setup .NET
      uses: actions/setup-dotnet@v1
      with:
        dotnet-version: 6.0.x
    - name: Restore .NET dependencies
      run: dotnet restore
    - name: Build .NET
      run: dotnet build --no-restore
    - name: Test .NET
      run: dotnet test --no-build --verbosity normal
    - name: Publish .NET
      run: |
        dotnet publish /p:PublishProfile=Release-win-x86 -c Release
        dotnet publish /p:PublishProfile=Release-win-x64 -c Release
    - name: Upload Published Artifact
      uses: actions/upload-artifact@v2
      with:
        name: softwarename
        path: | 
          /home/runner/work/solution/project/Software/win-x86/
          /home/runner/work/solution/project/Software/win-x64/

The error:

Upload Published Artifact
  Run actions/upload-artifact@v2
  Warning: No files were found with the provided path: 
  /home/runner/work/solution/project/Software/win-x86/
  /home/runner/work/solution/project/Software/win-x64/. No artifacts will be uploaded.
Download Published Artifact
  Run actions/download-artifact@v2
  Starting download for softwarename
  Error: Unable to find any artifacts for the associated workflow

I read here that I need to change actions/upload-artifact@v2 to actions/[email protected], that I tried and failed with the same error.

Any Idea how to fix this issue?

CodePudding user response:

Don't rely on:

/home/runner/work/solution/project

Instead use

${{ env.GITHUB_WORKSPACE }}/project

That way it points to the correct path for the runner independent of the operating system and configuration

In your case, make change like following:

...
${{ env.GITHUB_WORKSPACE }}\Software\win-x64
...
  • Related