Skip to content

Commit c9ce75c

Browse files
ANcpLuaclaude
andcommitted
fix: add OIDC token authentication for NuGet Trusted Publishing
- Request OIDC token from GitHub Actions - Pass token as API key to dotnet nuget push - This enables Trusted Publishing without storing secrets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 21b1c29 commit c9ce75c

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

.github/workflows/nuget-publish.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,14 @@ jobs:
4444

4545
- name: Publish packages to NuGet.org
4646
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
47+
env:
48+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4749
run: |
50+
# Request OIDC token for NuGet Trusted Publishing
51+
OIDC_TOKEN=$(curl -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=api://AzureADTokenExchange" | jq -r '.value')
52+
53+
# Push package with OIDC token
4854
dotnet nuget push ./nupkg/*.nupkg \
4955
--source https://api.nuget.org/v3/index.json \
56+
--api-key "$OIDC_TOKEN" \
5057
--skip-duplicate

SWEN3.Paperless.RabbitMq/Publishing/GenAIPublishingExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ public static class GenAIPublishingExtensions
1919
/// <param name="publisher">The RabbitMQ publisher instance.</param>
2020
/// <param name="command">The GenAI command to publish.</param>
2121
/// <returns>A task representing the asynchronous operation.</returns>
22+
/// <example>
23+
/// <code>var command = new GenAICommand(jobId, text);</code>
24+
/// <code>await publisher.PublishGenAICommandAsync(command);</code>
25+
/// </example>
2226
public static async Task PublishGenAICommandAsync<T>(this IRabbitMqPublisher publisher, T command)
2327
where T : class =>
2428
await publisher.PublishAsync(RabbitMqSchema.GenAICommandRouting, command).ConfigureAwait(false);

SWEN3.Paperless.RabbitMq/RabbitMqExtensions.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace SWEN3.Paperless.RabbitMq;
1212
/// <summary>
1313
/// <para>Use <see cref="PublishingExtensions.PublishOcrCommandAsync{T}" /> to publish OCR commands.</para>
1414
/// <para>Use <see cref="PublishingExtensions.PublishOcrEventAsync{T}" /> to publish OCR events.</para>
15+
/// <para>Use <see cref="GenAIPublishingExtensions.PublishGenAICommandAsync{T}" /> to publish GenAI commands (e.g., summaries).</para>
1516
/// <para>Use <see cref="GenAIPublishingExtensions.PublishGenAIEventAsync{T}" /> to publish GenAI events.</para>
1617
/// <para>Use <see cref="IRabbitMqConsumerFactory.CreateConsumerAsync{T}" /> to create message consumers.</para>
1718
/// <para>Use <see cref="PaperlessEndpointExtensions.MapOcrEventStream" /> to map OCR SSE endpoint.</para>

0 commit comments

Comments
 (0)