Skip to content

Commit

Permalink
NUKE fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
jp2masa committed Sep 5, 2024
1 parent 94126a1 commit 8578341
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 38 deletions.
85 changes: 47 additions & 38 deletions build/_build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public static int Main() =>

private SemanticVersion? TagVersion =>
TagName is not null
&& SemanticVersion.TryParse(TagName, out var version)
&& TagName.Length >= 2
&& TagName[0] == 'v'
&& SemanticVersion.TryParse(TagName[1..], out var version)
? version
: null;

Expand Down Expand Up @@ -184,48 +186,55 @@ TagVersion is not null
)
.Requires(() => GitHubToken)
.Executes(
new Func<Task>(
async () =>
async () =>
{
var repositoryId = GetVariable<long>("GITHUB_REPOSITORY_ID");

var client = new GitHubClient(
new ProductHeaderValue("jp2masa"),
new Octokit.Internal.InMemoryCredentialStore(
new Credentials(GitHubToken)
)
);

var release = await client
.Repository
.Release
.Create(
repositoryId,
new NewRelease(TagName!)
{
Draft = true,
Name = TagName!,
Prerelease = TagVersion!.IsPrerelease
}
);

// preserve order
foreach (var nupkg in NupkgArtifactsPath.GetFiles())
{
var client = new GitHubClient(
new ProductHeaderValue("jp2masa"),
new Octokit.Internal.InMemoryCredentialStore(
new Credentials(GitHubToken)
)
);
using var ms = new MemoryStream(nupkg.ReadAllBytes());

var release = await client
await client
.Repository
.Release
.Create(
GetVariable<long>("GITHUB_REPOSITORY_ID"),
new NewRelease(TagName!)
{
Name = TagName!,
Prerelease = TagVersion!.IsPrerelease
}
);

// preserve order
foreach (var nupkg in NupkgArtifactsPath.GetFiles())
{
using var ms = new MemoryStream(nupkg.ReadAllBytes());

await client
.Repository
.Release
.UploadAsset(
release,
new ReleaseAssetUpload(
nupkg.Name,
"application/octet-stream",
ms,
null
)
);
}
.UploadAsset(
release,
new ReleaseAssetUpload(
nupkg.Name,
"application/octet-stream",
ms,
null
)
);
}
)

await client.Repository.Release.Edit(
repositoryId,
release.Id,
new ReleaseUpdate() { Draft = false }
);
}
);

private static bool StringEqualsOrdinalIgnoreCase(string? x, string? y) =>
Expand Down
4 changes: 4 additions & 0 deletions build/_build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.12.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.1" />
<PackageReference Include="NuGet.Packaging" Version="6.7.1" />
<PackageReference Include="Nuke.Common" Version="8.0.0" />
<PackageReference Include="System.Formats.Asn1" Version="8.0.1" />
</ItemGroup>

</Project>

0 comments on commit 8578341

Please sign in to comment.