From 328d6849df7fbf29cc6d14f4eda53a87f2f9e3ae Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 31 Oct 2023 14:26:42 +0000 Subject: [PATCH] Avoid cloning Polly Avoid cloning Polly to get the .NET SDK version to use, and instead output the value from the actions/setup-dotnet step in the build job. --- .github/workflows/build.yml | 47 ++++++++++--------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6bb142535c4..1546c7513e7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,6 +29,9 @@ jobs: # HACK Running on Windows instead of Linux due to https://github.com/stryker-mutator/stryker-net/issues/2741 RUN_MUTATION_TESTS: ${{ matrix.os_name == 'windows' && !startsWith(github.ref, 'refs/tags/') && 'true' || 'false' }} + outputs: + dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }} + strategy: fail-fast: false matrix: @@ -50,6 +53,7 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 + id: setup-dotnet - name: Setup NuGet cache uses: actions/cache@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2 @@ -107,15 +111,10 @@ jobs: with: name: packages-windows - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - path: Polly - - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 with: - global-json-file: Polly/global.json + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Validate NuGet packages shell: pwsh @@ -134,7 +133,7 @@ jobs: } publish-github: - needs: validate-packages + needs: [ build, validate-packages ] permissions: packages: write runs-on: ubuntu-latest @@ -149,21 +148,16 @@ jobs: with: name: packages-windows - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - path: Polly - - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 with: - global-json-file: Polly/global.json + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Publish NuGet packages to GitHub Packages run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --skip-duplicate --no-symbols --source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json sign: - needs: publish-github + needs: [ build, publish-github ] runs-on: windows-latest if: | github.event.repository.fork == false && @@ -183,15 +177,10 @@ jobs: name: signing-config path: signing-config - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - path: Polly - - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 with: - global-json-file: Polly/global.json + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Install Sign CLI tool run: dotnet tool install --tool-path . sign --version 0.9.1-beta.23530.1 @@ -222,7 +211,7 @@ jobs: if-no-files-found: error validate-signed-packages: - needs: sign + needs: [ build, sign ] runs-on: windows-latest steps: @@ -231,15 +220,10 @@ jobs: with: name: signed-packages - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - path: Polly - - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 with: - global-json-file: Polly/global.json + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Validate NuGet packages shell: pwsh @@ -328,7 +312,7 @@ jobs: } publish-nuget: - needs: validate-signed-packages + needs: [ build, validate-signed-packages ] runs-on: ubuntu-latest steps: @@ -337,15 +321,10 @@ jobs: with: name: signed-packages - - name: Checkout code - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - with: - path: Polly - - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 with: - global-json-file: Polly/global.json + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Push signed NuGet packages to NuGet.org run: dotnet nuget push "*.nupkg" --api-key ${{ secrets.NUGET_TOKEN }} --skip-duplicate --source https://api.nuget.org/v3/index.json