Skip to content

Commit

Permalink
Update Build.cs
Browse files Browse the repository at this point in the history
Signed-off-by: timyhac <timyhac@gmail.com>
  • Loading branch information
timyhac authored Jul 8, 2024
1 parent 4a893fc commit 5625d8b
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,40 +173,20 @@ class Build : NukeBuild

});


private bool PackageExistsInNugetOrg(string packageName)
{
var nugetSource = "https://api.nuget.org";
var uri = $"{nugetSource}/v3-flatcontainer/{packageName.ToLowerInvariant()}/index.json";

try
{
HttpDownloadString(uri);
return true;
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
// https://github.com/alirezanet/publish-nuget/blob/master/index.js#L118
return false;
}
}

private void PushAndTag(string packageFilename, string tag)
{
// If the tag already exists, go no further
if (Git($"tag -l {tag}").Any())
{
return;
}

// Push the nuget package
DotNetNuGetPush(s => s
var output = DotNetNuGetPush(s => s
.SetTargetPath(ArtifactsDirectory / packageFilename)
.SetSource(NugetApiUrl)
.SetApiKey(NugetApiKey)
.EnableSkipDuplicate()
);

// Add the git tag and push
if (output.Any(line => line.Text.Contains("Conflict", StringComparison.InvariantCultureIgnoreCase))) {
Log.Information("{0} already exists in package repository", packageFilename);
return;
}

Git($"tag {tag}");
Git($"push origin {tag}");
}
Expand Down

0 comments on commit 5625d8b

Please sign in to comment.