Repository navigation
Use nuget.org Trusted Publishing in Build and Publish workflow - #1129
Conversation
Node.js 20 is deprecated on GitHub Actions runners. Bump each action to the lowest major version that runs on Node.js 24: - actions/checkout v3/v4 -> v5 - actions/setup-dotnet v4 -> v5 - actions/setup-node v4 -> v5 - actions/upload-artifact v4 -> v6 - actions/download-artifact v4 -> v7 - dawidd6/action-download-artifact v8 -> v17
Replace the long-lived NUGET_API_KEY secret with a short-lived API key obtained from nuget.org via GitHub OIDC (NuGet/login). The key is passed to the Nuke build as NUGET_API_KEY, so nuke/Build.cs is unchanged.
|
NuGet Trusted Publishing is configured on nuget.org for ElectronNET/Electron.NET → Build and Publish.yml, scoped to new versions of existing ElectronNET.Core* packages. NUGET_USER was already present in the repository. PR #1129 was merged as 4eeb98a; the workflow now exchanges GitHub OIDC for a short-lived NuGet key via NuGet/login@v1. Post-merge validation on develop has not reached the publish step: run #175 failed its Integration-Tests gate (88 Electron startup timeouts on ubuntu-24.04/Electron 30.4.0, one macOS 26 test failure, and unsupported macos-14 runner configuration). The retry also left the gate failed, so Publish was skipped and no package was published. The existing NUGET_API_KEY secret remains until a successful Trusted Publishing publish is verified. Run: https://github.com/ElectronNET/Electron.NET/actions/runs/42874033087 |
Addresses the workflow part of #1128.
Note
This branch is based on #1127 (which also changes
Build and Publish.yml), so it includes that PR's commit until #1127 is merged. Only the last commit (Use nuget.org Trusted Publishing in Build and Publish workflow) belongs to this PR.Changes
Replaces the long-lived
NUGET_API_KEYsecret with nuget.org Trusted Publishing:Publishjob getsid-token: writeso it can request a GitHub OIDC token, andcontents: write, which is still needed to create the GitHub release (an explicitpermissionsblock replaces the job's default token permissions).NuGet/login@v1step exchanges the OIDC token for a short-lived nuget.org API key.Buildstep asNUGET_API_KEY, the variable the NukePublishPackagestarget already reads, sonuke/Build.csis unchanged.NUGET_API_KEYsecret reference is removed.Required setup before merging
ElectronNET.Core*packages: username → Trusted Publishing → add a GitHub Actions policy:ElectronNETElectron.NETBuild and Publish.ymlNUGET_USERcontaining the nuget.org profile name (not email) of that policy owner.After a successful publish, the old
NUGET_API_KEYrepository secret can be deleted.