Repository navigation
feat(ci): publish to NuGet with trusted publishing - #33
Merged
Merged
Conversation
Replaces the long-lived NUGET_API_KEY with an OIDC token exchanged for a
key that lives one hour. The 1.10.0 release failed because that key had
expired or been revoked:
403 (The specified API key is invalid, has expired, or does not have
permission to access the specified package.)
Nothing warned; the package built fine and the push was rejected. A
short-lived key removes both the rotation and the silent-expiry problem.
The publish job now requests id-token: write, exchanges the token via
NuGet/login, and pushes with the key that returns. Declaring permissions
drops the job to contents: read for everything else, which is all the
rest of it needs.
Which refs may publish is still the job's own `if:` -- tags only, pushes
only, this repository only. The policy leaves Environment blank to match.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the long-lived
NUGET_API_KEYwith an OIDC token exchanged for a key that lives one hour.The
1.10.0release failed on it (run 41844611368):The package built fine; only the push was rejected, and nothing warned beforehand. NuGet caps keys at 365 days, so this recurs on a timer. A short-lived key removes both the rotation and the silent-expiry failure mode.
Changes
permissions: id-token: writeon the publish job, pluscontents: read— naming permissions drops everything else, which is all the job needs.NuGet/login@v1exchanges the token; the push usessteps.nuget-login.outputs.NUGET_API_KEY.secrets.NUGET_API_KEYis gone.Ref control is unchanged: the job's own
if:already restricts to tags, pushes, and this repository.Needs doing alongside the merge
Trusted publishing policy on nuget.org, owned by the tinify organization (the
Tinifypackage is owned bytinify, not a personal account):tinifytinify-netci-cd.ymlTinifyNUGET_USERsecret — the nuget.org profile name, not an email. The action documents this only as "your NuGet account username" and says nothing about organization-owned policies, so if the exchange 401s, that value is the first thing to try changing.Delete
NUGET_API_KEYonce a publish has succeeded, not before.The repo is public, so the 7-day "pending full activation" window that private repos get does not apply.
Still outstanding in this repo
on: [push, pull_request]runs everything twice on every PR branch.Preserve_Should_IncludeOtherOptions_IfSetflakes through static state inHelper; it has failed on both Windows and macOS on identical commits.Check if properly taggedstep prints "Version in tinify/version.py" while readingTinify.csproj.🤖 Generated with Claude Code