Skip to content

Hardcode nuget.org user for Trusted Publishing #2

Hardcode nuget.org user for Trusted Publishing

Hardcode nuget.org user for Trusted Publishing #2

Workflow file for this run

name: publish
# Publishes Hellio.Messaging to NuGet via Trusted Publishing (OIDC) — no API key.
# Triggered by pushing a version tag (v*), or manually from the Actions tab.
#
# One-time setup on nuget.org (Account -> Trusted Publishing) create a policy with:
# Package owner: HellioSolutions Repository Owner: HellioSolutions
# Repository: hellio-dotnet Workflow File: publish.yml
# Environment: main
# The `user` below is the nuget.org account username that owns the policy.
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
publish:
runs-on: ubuntu-latest
environment: main
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
- name: Restore
run: dotnet restore
- name: Test
run: dotnet test --configuration Release
- name: Pack
run: dotnet pack src/Hellio.Messaging/Hellio.Messaging.csproj --configuration Release --output ./artifacts
- name: NuGet login (Trusted Publishing OIDC)
id: login
uses: NuGet/login@v1
with:
user: HellioSolutions
- name: Push to NuGet
run: dotnet nuget push "./artifacts/*.nupkg" --api-key "${{ steps.login.outputs.NUGET_API_KEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate