diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9ea74c..17d42e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,11 +49,10 @@ jobs: needs: build runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') + permissions: + id-token: write # enable GitHub OIDC token issuance for NuGet Trusted Publishing steps: - - name: Checkout - uses: actions/checkout@v6 - - name: Setup .NET 10 uses: actions/setup-dotnet@v5 with: @@ -65,8 +64,18 @@ jobs: name: nuget-package path: ./artifacts + # Exchange the GitHub OIDC token for a short-lived (1-hour) nuget.org API + # key. Requires a matching Trusted Publishing policy on nuget.org. Run this + # immediately before the push so the temporary key doesn't expire. + - name: NuGet login (OIDC -> temp API key) + uses: NuGet/login@v1 + id: login + with: + # nuget.org username (profile name), NOT an email address. + user: ${{ secrets.NUGET_USER }} + - name: Publish to NuGet - run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate release: needs: publish diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..cce7333 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,23 @@ + + + true + + + + + + + + + + + + + + + + + + + diff --git a/src/NextIteration.SpectreConsole.Settings/NextIteration.SpectreConsole.Settings.csproj b/src/NextIteration.SpectreConsole.Settings/NextIteration.SpectreConsole.Settings.csproj index daa769c..dbb8c93 100644 --- a/src/NextIteration.SpectreConsole.Settings/NextIteration.SpectreConsole.Settings.csproj +++ b/src/NextIteration.SpectreConsole.Settings/NextIteration.SpectreConsole.Settings.csproj @@ -39,10 +39,10 @@ - - - - + + + + diff --git a/tests/NextIteration.SpectreConsole.Settings.Tests/NextIteration.SpectreConsole.Settings.Tests.csproj b/tests/NextIteration.SpectreConsole.Settings.Tests/NextIteration.SpectreConsole.Settings.Tests.csproj index 294ba4d..44d3714 100644 --- a/tests/NextIteration.SpectreConsole.Settings.Tests/NextIteration.SpectreConsole.Settings.Tests.csproj +++ b/tests/NextIteration.SpectreConsole.Settings.Tests/NextIteration.SpectreConsole.Settings.Tests.csproj @@ -22,15 +22,15 @@ - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all