Skip to content

Commit 19b64c1

Browse files
committed
Switch to NuGet Trusted Publishing
1 parent 49eb0f2 commit 19b64c1

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:
@@ -30,18 +14,19 @@ jobs:
3014
- uses: actions/checkout@v4
3115
with:
3216
fetch-depth: 0
17+
3318
- uses: actions/setup-dotnet@v4
3419
with:
3520
dotnet-version: |
3621
6.0.x
22+
3723
- name: Cache .nuke/temp, ~/.nuget/packages
3824
uses: actions/cache@v4
3925
with:
4026
path: |
4127
.nuke/temp
4228
~/.nuget/packages
4329
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
30+
4431
- name: Run './build.cmd Verify Cover Pack'
4532
run: ./build.cmd Verify Cover Pack --no-logo
46-
env:
47-
GitHubToken: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 18 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_release --host GitHubActions
13-
#
14-
# </auto-generated>
15-
# ------------------------------------------------------------------------------
16-
171
name: release
182

193
on:
@@ -25,34 +9,50 @@ jobs:
259
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+
3633
- name: Cache .nuke/temp, ~/.nuget/packages
3734
uses: actions/cache@v4
3835
with:
3936
path: |
4037
.nuke/temp
4138
~/.nuget/packages
4239
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
40+
4341
- name: Run './build.cmd Verify Cover Publish'
4442
run: ./build.cmd Verify Cover Publish --no-logo
4543
env:
46-
GitHubToken: ${{ secrets.GITHUB_TOKEN }}
47-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
44+
NUGET_API_KEY: ${{ steps.nugetLogin.outputs.NUGET_API_KEY }}
45+
4846
- uses: actions/upload-artifact@v4
4947
with:
5048
name: testresults
5149
path: artifacts/testresults
50+
5251
- uses: actions/upload-artifact@v4
5352
with:
5453
name: reports
5554
path: artifacts/reports
55+
5656
- uses: actions/upload-artifact@v4
5757
with:
5858
name: packages

build/Build.cs

Lines changed: 2 additions & 5 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;
@@ -231,4 +228,4 @@ public static class Secrets
231228
{
232229
public const string NuGetApiKey = "NUGET_API_KEY";
233230
}
234-
}
231+
}

0 commit comments

Comments
 (0)