Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 9 additions & 2 deletions build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ 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
)
.Build();

protected override async Task<Release?> 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<VersionModule>();
var version =
versionResult.ValueOrDefault
Expand Down
14 changes: 11 additions & 3 deletions build/PipelineCLI/Modules/PublishNuGetModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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))
{
Expand All @@ -58,7 +66,7 @@ CancellationToken cancellationToken
{
Path = package,
Source = nugetSettings.Value.FeedUrl,
ApiKey = nugetSettings.Value.GetNuGetAPIKey(),
ApiKey = apiKey,
SkipDuplicate = true,
},
cancellationToken: cancellationToken
Expand Down