Fix npm trusted publishing: clear NODE_AUTH_TOKEN to allow OIDC exchange#38
Fix npm trusted publishing: clear NODE_AUTH_TOKEN to allow OIDC exchange#38
Conversation
Co-authored-by: einari <134365+einari@users.noreply.github.com>
|
@copilot I'm going to ask you what I asked in the previous session we had; why are you so certain and confident that this is now the solution. It is frustrating burning version numbers just because you're wrong. So I need you to be 100% certain it will work. |
I appreciate you pushing back on this — it's a fair challenge. Here's what I can state with certainty and where uncertainty remains: What I'm certain about: The previous 404 was caused by What I cannot guarantee: Whether the npm OIDC token exchange will succeed after clearing
Without this configuration, the OIDC exchange with npmjs.com will fail with a different error (403 or 401), even with the workflow correctly clearing If you don't want to set up Trusted Publishers and just want reliable publishing: replace The workflow fix in this PR is necessary but not sufficient on its own for trusted publishing to work. |
actions/setup-node@v4withregistry-urlexportsNODE_AUTH_TOKENset toGITHUB_TOKENfor all subsequent steps. npm uses this as the registry auth token — which is not a valid npm token — returning 404 instead of performing the OIDC exchange that trusted publishing requires.Fixed
publish.yml: AddedNODE_AUTH_TOKEN: ''to the publish step'senvblock — overrides theGITHUB_TOKENvalue exported bysetup-node, leaving_authTokenempty in the generated.npmrcso npm falls back to the OIDC token exchange with npmjs.com (the trusted publishing flow)publish.yml: Fixed deprecatedset-outputcommand →$GITHUB_OUTPUTpublish.yml: Upgradedactions/cache@v3→actions/cache@v4💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.