Skip to content

Publish to NuGet from GitHub releases with trusted publishing - #196

Closed
at0dd wants to merge 1 commit into
mainfrom
publish-with-trusted-publishing
Closed

at0dd wants to merge 1 commit into
mainfrom
publish-with-trusted-publishing

Conversation

@at0dd

@at0dd at0dd commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Adds a Publish workflow that pushes the package to nuget.org when a GitHub release is published. It uses NuGet trusted publishing, so no API key is stored: NuGet/login exchanges the run's GitHub OIDC token for a one-hour key.

What it does

  1. Checks the release tag matches <Version> in src/TeslaAPI.csproj, and fails if not.
  2. Runs the tests.
  3. Packs in Release.
  4. Pushes the .nupkg to nuget.org. The .snupkg goes up with it.

Setup needed before it works

  1. On nuget.org: sign in, open your username menu, choose Trusted Publishing, and add a policy:
    • Repository owner: at0dd
    • Repository: tesla-api
    • Workflow file: publish.yml
    • Environment: leave empty.
  2. In GitHub: add a repository secret NUGET_USER containing your nuget.org username (your profile name, not your email). Go to Settings → Secrets and variables → Actions → New repository secret.

Checked locally: the version check returns 1.2.0, the pack step produces Tesla-API.1.2.0.nupkg and .snupkg, and the YAML parses. The workflow itself only runs on a published release, so it can't be tested from this PR.

README.md gains a short Releasing section.

Add a Publish workflow that runs when a GitHub release is published.
It checks the tag matches <Version>, runs the tests, packs, and pushes
the package and symbols to nuget.org. NuGet/login exchanges the run's
OIDC token for a one-hour API key, so no key is stored.

Needs a trusted publishing policy on nuget.org for this repo and
publish.yml, and a NUGET_USER secret with the nuget.org username.
@at0dd at0dd closed this Nov 24, 2026
@at0dd
at0dd deleted the publish-with-trusted-publishing branch November 24, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant