From 9b34381c9d87c650ad97e94211a3eb19b693c853 Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 31 Oct 2023 18:25:31 +0000 Subject: [PATCH] Pin .NET SDK version Use the same .NET SDK version to publish NuGet packages as to build them where there is no global.json to specify it. --- .github/workflows/build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b23c574d8..b2127fc83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,6 +25,9 @@ jobs: name: ${{ matrix.os }} runs-on: ${{ matrix.os }} + outputs: + dotnet-sdk-version: ${{ steps.setup-dotnet.outputs.dotnet-version }} + strategy: fail-fast: false matrix: @@ -45,6 +48,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 @@ -88,6 +92,8 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 + with: + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Validate NuGet packages shell: pwsh @@ -106,7 +112,7 @@ jobs: } publish-github: - needs: validate-packages + needs: [ build, validate-packages ] permissions: packages: write runs-on: ubuntu-latest @@ -123,12 +129,14 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 + with: + 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 publish-nuget: - needs: validate-packages + needs: [ build, validate-packages ] runs-on: ubuntu-latest if: | github.event.repository.fork == false && @@ -142,6 +150,8 @@ jobs: - name: Setup .NET SDK uses: actions/setup-dotnet@3447fd6a9f9e57506b15f895c5b76d3b197dc7c2 # v3.2.0 + with: + dotnet-version: ${{ needs.build.outputs.dotnet-sdk-version }} - name: Push 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