Skip to content

Commit

Permalink
Fix publish logic (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma authored Feb 16, 2024
1 parent 7e14235 commit 861ebc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 27 deletions.
38 changes: 12 additions & 26 deletions build/Build.Publish.cs
Original file line number Diff line number Diff line change
@@ -1,50 +1,36 @@
using System.Collections.Generic;

using Nuke.Common;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Components;
using static Nuke.Common.Tools.DotNet.DotNetTasks;

public partial class Build
{
string NuGetSource => "https://api.nuget.org/v3/index.json";
[Parameter] [Secret] string NuGetApiKey;

string MyGetGetSource => "https://www.myget.org/F/test262harness/api/v2/package";
[Parameter] [Secret] string MyGetApiKey;

string ApiKeyToUse => IsTaggedBuild ? NuGetApiKey : MyGetApiKey;
string SourceToUse => IsTaggedBuild ? NuGetSource : MyGetGetSource;
string ApiKeyToUse => IsTaggedBuild ? ((IPublish) this).NuGetApiKey : MyGetApiKey;
string SourceToUse => IsTaggedBuild ? ((IPublish) this).NuGetSource : MyGetGetSource;

Target Publish => _ => _
.OnlyWhenDynamic(() => IsRunningOnWindows && (GitRepository.IsOnMainOrMasterBranch() || IsTaggedBuild))
public Target Publish => _ => _
.OnlyWhenDynamic(() => !IsRunningOnWindows && (GitRepository.IsOnMainOrMasterBranch() || IsTaggedBuild))
.DependsOn<IPack>()
.Requires(() => NuGetApiKey, () => MyGetApiKey)
.Requires(() => ((IPublish) this).NuGetApiKey, () => MyGetApiKey)
.Executes(() =>
{
DotNetNuGetPush(_ => _
.Apply(PushSettingsBase)
.Apply(PushSettings)
.CombineWith(PushPackageFiles, (_, v) => _
.Apply(((IPublish) this).PushSettingsBase)
.Apply(((IPublish) this).PushSettings)
.CombineWith(((IPublish) this).PushPackageFiles, (_, v) => _
.SetTargetPath(v))
.Apply(PackagePushSettings),
PushDegreeOfParallelism,
PushCompleteOnFailure);
.Apply(((IPublish) this).PackagePushSettings),
((IPublish) this).PushDegreeOfParallelism,
((IPublish) this).PushCompleteOnFailure);
});

Configure<DotNetNuGetPushSettings> PushSettingsBase => _ => _
public Configure<DotNetNuGetPushSettings> PushSettings => _ => _
.SetSource(SourceToUse)
.SetApiKey(ApiKeyToUse)
.EnableSkipDuplicate();

Configure<DotNetNuGetPushSettings> PushSettings => _ => _;
Configure<DotNetNuGetPushSettings> PackagePushSettings => _ => _;

IEnumerable<AbsolutePath> PushPackageFiles => ArtifactsDirectory.GlobFiles("*.nupkg");

bool PushCompleteOnFailure => true;
int PushDegreeOfParallelism => 2;
}
2 changes: 1 addition & 1 deletion build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
using Nuke.Components;

[ShutdownDotNetAfterServerBuild]
partial class Build : NukeBuild, ITest, IPack
partial class Build : NukeBuild, ITest, IPack, IPublish
{
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
Expand Down

0 comments on commit 861ebc4

Please sign in to comment.