Skip to content

Commit 22d451f

Browse files
committed
Switch to NuGet Trusted Publishing (#1533)
1 parent 4c09359 commit 22d451f

3 files changed

Lines changed: 23 additions & 41 deletions

File tree

.github/workflows/continuous.yml

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
# ------------------------------------------------------------------------------
2-
# <auto-generated>
3-
#
4-
# This code was generated.
5-
#
6-
# - To turn off auto-generation set:
7-
#
8-
# [GitHubActions (AutoGenerate = false)]
9-
#
10-
# - To trigger manual generation invoke:
11-
#
12-
# nuke --generate-configuration GitHubActions_continuous --host GitHubActions
13-
#
14-
# </auto-generated>
15-
# ------------------------------------------------------------------------------
16-
171
name: continuous
182

193
on:
@@ -32,11 +16,12 @@ jobs:
3216
- uses: actions/checkout@v4
3317
with:
3418
fetch-depth: 0
19+
3520
- uses: actions/setup-dotnet@v4
3621
with:
3722
dotnet-version: |
3823
6.0.x
24+
25+
3926
- name: Run './build.cmd Verify Cover Pack'
4027
run: ./build.cmd Verify Cover Pack --no-logo
41-
env:
42-
GitHubToken: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
1-
# ------------------------------------------------------------------------------
2-
# <auto-generated>
3-
#
4-
# This code was generated.
5-
#
6-
# - To turn off auto-generation set:
7-
#
8-
# [GitHubActions (AutoGenerate = false)]
9-
#
10-
# - To trigger manual generation invoke:
11-
#
12-
# nuke --generate-configuration GitHubActions_release --host GitHubActions
13-
#
14-
# </auto-generated>
15-
# ------------------------------------------------------------------------------
16-
171
name: release
182

193
on:
@@ -22,30 +6,46 @@ on:
226
- 'v*'
237

248
jobs:
25-
windows-latest:
9+
windows-latest:
2610
name: windows-latest
2711
runs-on: windows-latest
12+
13+
permissions:
14+
id-token: write
15+
2816
steps:
2917
- uses: actions/checkout@v4
3018
with:
3119
fetch-depth: 0
20+
21+
# Read more: https://devblogs.microsoft.com/dotnet/enhanced-security-is-here-with-the-new-trust-publishing-on-nuget-org/
22+
- name: NuGet login (OIDC → temp API key)
23+
uses: NuGet/login@v1
24+
id: nugetLogin
25+
with:
26+
user: ${{ secrets.NUGET_USER }}
27+
3228
- uses: actions/setup-dotnet@v4
3329
with:
3430
dotnet-version: |
3531
6.0.x
32+
33+
3634
- name: Run './build.cmd Verify Cover Publish'
3735
run: ./build.cmd Verify Cover Publish --no-logo
3836
env:
39-
GitHubToken: ${{ secrets.GITHUB_TOKEN }}
40-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
37+
NUGET_API_KEY: ${{ steps.nugetLogin.outputs.NUGET_API_KEY }}
38+
4139
- uses: actions/upload-artifact@v4
4240
with:
4341
name: testresults
4442
path: artifacts/testresults
43+
4544
- uses: actions/upload-artifact@v4
4645
with:
4746
name: reports
4847
path: artifacts/reports
48+
4949
- uses: actions/upload-artifact@v4
5050
with:
5151
name: packages

build/Build.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,14 @@
2424
AutoGenerate = false,
2525
OnPullRequestBranches = new[] { MasterBranch, ReleaseBranch },
2626
PublishArtifacts = false,
27-
InvokedTargets = new[] { nameof(Verify), nameof(Cover), nameof(Pack) },
28-
EnableGitHubToken = true)]
27+
InvokedTargets = new[] { nameof(Verify), nameof(Cover), nameof(Pack) })]
2928
[GitHubActions(
3029
"release",
3130
GitHubActionsImage.WindowsLatest,
3231
AutoGenerate = false,
3332
OnPushTags = new[] { "v*" },
3433
PublishArtifacts = true,
3534
InvokedTargets = new[] { nameof(Verify), nameof(Cover), nameof(Publish) },
36-
EnableGitHubToken = true,
3735
ImportSecrets = new[] { Secrets.NuGetApiKey })]
3836
partial class Build : NukeBuild
3937
{
@@ -50,7 +48,6 @@ partial class Build : NukeBuild
5048
[GitVersion] readonly GitVersion GitVersion;
5149
[CI] readonly GitHubActions GitHubActions;
5250

53-
[Parameter("GitHub auth token", Name = "github-token"), Secret] readonly string GitHubToken;
5451
[Parameter("Forces the continuous integration build flag")] readonly bool CI;
5552

5653
[Secret] [Parameter("NuGet API Key (secret)", Name = Secrets.NuGetApiKey)] readonly string NuGetApiKey;

0 commit comments

Comments
 (0)