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
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ jobs:
Build__TestProjects: ${{ matrix.project }}
Build__RunLint: "false"
Build__RunPack: "false"
run: dotnet run --project build/PipelineCLI/PipelineCLI.csproj --configuration Release
run: dotnet run --project build/PipelineCLI/PipelineCLI.csproj --configuration Release
3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ jobs:
- name: Run release pipeline
if: steps.version.outputs.should_publish == 'true'
env:
Release__ShouldPublish: true
Release__Mode: NuGet
GITHUB_TOKEN: ${{ github.token }}
NuGet__ApiKey: ${{ secrets.NUGET__APIKEY }}
run: dotnet run --project build/PipelineCLI/PipelineCLI.csproj --configuration Release
12 changes: 3 additions & 9 deletions build/PipelineCLI/Modules/CreateGitHubReleaseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ protected override ModuleConfiguration Configure() =>
ModuleConfiguration
.Create()
.WithSkipWhen(_ =>
releaseSettings.Value.Mode is ReleaseMode.NuGet or ReleaseMode.GitHubRelease
? SkipDecision.DoNotSkip
: SkipDecision.Skip(
"Release publishing is disabled. Set Release__Mode=GitHubRelease or Release__Mode=NuGet to create a GitHub release."
)
)
.WithSkipWhen(_ =>
string.IsNullOrWhiteSpace(gitSettings.Value.GetGitHubToken())
releaseSettings.Value.Mode is not (ReleaseMode.NuGet or ReleaseMode.GitHubRelease)
|| string.IsNullOrWhiteSpace(gitSettings.Value.GetGitHubToken())
? SkipDecision.Skip(
"GitHub access token is not configured. Set GitHub__AccessToken or GITHUB_TOKEN to create a GitHub release."
"GitHub release creation is disabled. Set Release__Mode=NuGet (or GitHubRelease) and GITHUB_TOKEN to create a GitHub release."
)
: SkipDecision.DoNotSkip
)
Expand Down
13 changes: 4 additions & 9 deletions build/PipelineCLI/Modules/PackModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,11 @@ protected override ModuleConfiguration Configure() =>
ModuleConfiguration
.Create()
.WithSkipWhen(_ =>
settings.Value.RunPack
? SkipDecision.DoNotSkip
: SkipDecision.Skip("Packing is disabled. Set Build__RunPack=true to enable it.")
)
.WithSkipWhen(_ =>
releaseSettings.Value.Mode != ReleaseMode.None
? SkipDecision.DoNotSkip
: SkipDecision.Skip(
"Packing is disabled. Set Release__Mode to something other than None to enable it."
!settings.Value.RunPack || releaseSettings.Value.Mode == ReleaseMode.None
? SkipDecision.Skip(
"Packing is disabled. Set Build__RunPack=true and Release__Mode to something other than None to enable it."
)
: SkipDecision.DoNotSkip
)
.Build();

Expand Down
13 changes: 4 additions & 9 deletions build/PipelineCLI/Modules/PublishLocalNuGetModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ protected override ModuleConfiguration Configure() =>
ModuleConfiguration
.Create()
.WithSkipWhen(ctx =>
ctx.IsRunningLocally()
? SkipDecision.DoNotSkip
: SkipDecision.Skip("Local NuGet Feed publishing is disabled. This module can only be run locally.")
)
.WithSkipWhen(_ =>
releaseSettings.Value.Mode == ReleaseMode.LocalNuGet
? SkipDecision.DoNotSkip
: SkipDecision.Skip(
"Local NuGet Feed publishing is disabled. Set Release__Mode=LocalNuGet to enable it."
!ctx.IsRunningLocally() || releaseSettings.Value.Mode != ReleaseMode.LocalNuGet
? SkipDecision.Skip(
"Local NuGet Feed publishing is disabled. Run the pipeline locally with Release__Mode=LocalNuGet to enable it."
)
: SkipDecision.DoNotSkip
)
.Build();

Expand Down
25 changes: 13 additions & 12 deletions build/PipelineCLI/Modules/PublishNuGetModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,10 @@ protected override ModuleConfiguration Configure() =>
ModuleConfiguration
.Create()
.WithSkipWhen(_ =>
releaseSettings.Value.Mode == ReleaseMode.NuGet
? SkipDecision.DoNotSkip
: SkipDecision.Skip(
"Release publishing is disabled. Set Release__Mode=NuGet to publish packages to nuget.org."
)
)
.WithSkipWhen(_ =>
string.IsNullOrWhiteSpace(nugetSettings.Value.GetNuGetAPIKey())
releaseSettings.Value.Mode != ReleaseMode.NuGet
|| string.IsNullOrWhiteSpace(nugetSettings.Value.GetNuGetAPIKey())
? SkipDecision.Skip(
"NuGet API key is not set. Set NuGet__APIKey or NUGET_APIKEY to publish packages."
"NuGet publishing is disabled. Set Release__Mode=NuGet and NuGet__ApiKey (or NUGET_APIKEY) to publish packages to nuget.org."
)
: SkipDecision.DoNotSkip
)
Expand All @@ -40,9 +34,16 @@ protected override ModuleConfiguration Configure() =>
CancellationToken cancellationToken
)
{
var packages = Directory
.EnumerateFiles(buildSettings.Value.ArtifactsFolder, "*.nupkg", SearchOption.TopDirectoryOnly)
.ToList();
var artifactsFolder = buildSettings.Value.ArtifactsFolder;
if (!Directory.Exists(artifactsFolder))
{
throw new InvalidOperationException(
$"The artifacts folder '{artifactsFolder}' does not exist. "
+ "Ensure the pack step ran (Release__Mode must not be None) before publishing."
);
}

var packages = Directory.EnumerateFiles(artifactsFolder, "*.nupkg", SearchOption.TopDirectoryOnly).ToList();

if (packages.Count == 0)
{
Expand Down
Loading