Skip to content

Commit 252183e

Browse files
committed
Update release workflow to use OIDC for NuGet auth
Updated the GitHub Actions workflow in `release.yml`: - Renamed the `build` job to `build-and-publish`. - Added OIDC-based authentication for NuGet, replacing the use of a long-lived API key with a short-lived token generated during the workflow. - Introduced a `NuGet login` step using `NuGet/login@v1`. - Updated `NuGet/setup-nuget` action from `v1.0.6` to `v1.1.1`. - Updated the `Publish` step to use the short-lived API key. - Improved security by removing reliance on GitHub Secrets for NuGet API keys.
1 parent a447ce0 commit 252183e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release
1+
name: Release
22

33
on:
44
release:
@@ -10,7 +10,10 @@ env:
1010
NUGET_PATH: './**/IeuanWalker.Maui.Breadcrumb.${{ github.event.release.tag_name }}.nupkg'
1111

1212
jobs:
13-
build:
13+
build-and-publish:
14+
permissions:
15+
id-token: write # enable GitHub OIDC token issuance for this job
16+
1417
runs-on: windows-latest
1518

1619
steps:
@@ -42,7 +45,14 @@ jobs:
4245
path: ${{ env.NUGET_PATH }}
4346

4447
- name: Setup NuGet
45-
uses: NuGet/setup-nuget@v1.0.6
48+
uses: NuGet/setup-nuget@v1.1.1
4649

50+
# Get a short-lived NuGet API key
51+
- name: NuGet login (OIDC → temp API key)
52+
uses: NuGet/login@v1
53+
id: login
54+
with:
55+
user: Ieuan
56+
4757
- name: Publish
48-
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{secrets.NUGET_API_KEY}}
58+
run: nuget push **\*.nupkg -Source 'https://api.nuget.org/v3/index.json' -ApiKey ${{steps.login.outputs.NUGET_API_KEY}}

0 commit comments

Comments
 (0)