From 5f74b653cdb6d97c0b1b612f8591b76a769809db Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Wed, 2 Sep 2026 09:01:58 +0100 Subject: [PATCH] chore: fixed pipeline --- .github/workflows/release.yml | 3 ++- .../Modules/CreateGitHubReleaseModule.cs | 11 +++++++++-- build/PipelineCLI/Modules/PublishNuGetModule.cs | 14 +++++++++++--- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9e79ec..044ded4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -47,5 +47,6 @@ jobs: env: Release__Mode: NuGet Build__TestFilter: "/*/*/*/*[Category=Unit]" - NuGet__ApiKey: ${{ secrets.NUGET_API_KEY }} + NuGet__ApiKey: ${{ secrets.NUGET__APIKEY }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: dotnet run --project build/PipelineCLI/PipelineCLI.csproj --configuration Release diff --git a/build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs b/build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs index 6d24f31..95ad3c1 100644 --- a/build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs +++ b/build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs @@ -18,9 +18,8 @@ protected override ModuleConfiguration Configure() => .Create() .WithSkipWhen(_ => releaseSettings.Value.Mode is not (ReleaseMode.NuGet or ReleaseMode.GitHubRelease) - || string.IsNullOrWhiteSpace(gitSettings.Value.GetGitHubToken()) ? SkipDecision.Skip( - "GitHub release creation is disabled. Set Release__Mode=NuGet (or GitHubRelease) and GITHUB_TOKEN to create a GitHub release." + "GitHub release creation is disabled. Set Release__Mode=NuGet or Release__Mode=GitHubRelease to create a GitHub release." ) : SkipDecision.DoNotSkip ) @@ -28,6 +27,14 @@ releaseSettings.Value.Mode is not (ReleaseMode.NuGet or ReleaseMode.GitHubReleas protected override async Task ExecuteAsync(IModuleContext context, CancellationToken cancellationToken) { + if (string.IsNullOrWhiteSpace(gitSettings.Value.GetGitHubToken())) + { + throw new InvalidOperationException( + "GitHub release creation is enabled (Release__Mode=NuGet or GitHubRelease) but no token is configured. " + + "Set GitHub__AccessToken or GITHUB_TOKEN to create a GitHub release." + ); + } + var versionResult = await context.GetModule(); var version = versionResult.ValueOrDefault diff --git a/build/PipelineCLI/Modules/PublishNuGetModule.cs b/build/PipelineCLI/Modules/PublishNuGetModule.cs index 9c8f74e..7140c97 100644 --- a/build/PipelineCLI/Modules/PublishNuGetModule.cs +++ b/build/PipelineCLI/Modules/PublishNuGetModule.cs @@ -21,9 +21,8 @@ protected override ModuleConfiguration Configure() => .Create() .WithSkipWhen(_ => releaseSettings.Value.Mode != ReleaseMode.NuGet - || string.IsNullOrWhiteSpace(nugetSettings.Value.GetNuGetAPIKey()) ? SkipDecision.Skip( - "NuGet publishing is disabled. Set Release__Mode=NuGet and NuGet__ApiKey (or NUGET_APIKEY) to publish packages to nuget.org." + "NuGet publishing is disabled. Set Release__Mode=NuGet to publish packages to nuget.org." ) : SkipDecision.DoNotSkip ) @@ -34,6 +33,15 @@ protected override ModuleConfiguration Configure() => CancellationToken cancellationToken ) { + var apiKey = nugetSettings.Value.GetNuGetAPIKey(); + if (string.IsNullOrWhiteSpace(apiKey)) + { + throw new InvalidOperationException( + "NuGet publishing is enabled (Release__Mode=NuGet) but no API key is configured. " + + "Set NuGet__ApiKey (or NuGet__NUGET_APIKEY), or configure the NUGET__APIKEY secret in CI." + ); + } + var artifactsFolder = buildSettings.Value.ArtifactsFolder; if (!Directory.Exists(artifactsFolder)) { @@ -58,7 +66,7 @@ CancellationToken cancellationToken { Path = package, Source = nugetSettings.Value.FeedUrl, - ApiKey = nugetSettings.Value.GetNuGetAPIKey(), + ApiKey = apiKey, SkipDuplicate = true, }, cancellationToken: cancellationToken