Create Release via GH Action v1 (#7)

This commit is contained in:
Matt Parker
2025-11-15 15:07:24 +10:00
committed by GitHub
parent 89e04ed084
commit c2928fbd2d
7 changed files with 74 additions and 2 deletions

View File

@@ -8,6 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGet.Versioning" />
<PackageReference Include="Octokit" />
<PackageReference Include="ParallelPipelines" />
</ItemGroup>

View File

@@ -24,6 +24,7 @@ builder.Services.AddParallelPipelines(
builder.Services
.AddStep<RestoreAndBuildStep>()
.AddStep<CreateWindowsRelease>()
.AddStep<CreateGithubRelease>()
;
using var host = builder.Build();

View File

@@ -0,0 +1,48 @@
using CliWrap.Buffered;
using Microsoft.Extensions.Configuration;
using NuGet.Versioning;
using Octokit;
using ParallelPipelines.Application.Attributes;
using ParallelPipelines.Domain.Entities;
using ParallelPipelines.Host.Helpers;
namespace Deploy.Steps;
[DependsOnStep<CreateWindowsRelease>]
public class CreateGithubRelease(IPipelineContext pipelineContext) : IStep
{
public async Task<BufferedCommandResult?[]?> RunStep(CancellationToken cancellationToken)
{
var github = new GitHubClient(new ProductHeaderValue("SharpIDE-CI"));
var token = pipelineContext.Configuration.GetValue<string>("GITHUB_TOKEN");
var credentials = new Credentials(token);
github.Credentials = credentials;
var version = NuGetVersion.Parse("0.1.1");
var versionString = version.ToNormalizedString();
var releaseTag = $"v{versionString}";
var newRelease = new NewRelease(releaseTag)
{
Name = releaseTag,
Body = "",
Draft = true,
Prerelease = false,
GenerateReleaseNotes = true
};
var owner = "MattParkerDev";
var repo = "SharpIDE";
var release = await github.Repository.Release.Create(owner, repo, newRelease);
var windowsReleaseZip = await PipelineFileHelper.GitRootDirectory.GetFile("./artifacts/publish-godot/sharpide-win-x64.zip");
await using var stream = windowsReleaseZip.OpenRead();
var upload = new ReleaseAssetUpload
{
FileName = $"sharpide-win-x64-{versionString}.zip",
ContentType = "application/octet-stream",
RawData = stream
};
var asset = await github.Repository.Release.UploadAsset(release, upload, cancellationToken);
return null;
}
}

View File

@@ -23,6 +23,8 @@ public class CreateWindowsRelease : IStep
cancellationToken
);
var windowsZipFile = await windowsPublishDirectory.ZipDirectoryToFile($"{PipelineFileHelper.GitRootDirectory.FullName}/artifacts/publish-godot/sharpide-win-x64.zip");
return [godotExportResult];
}
}

5
iac/should-release.cs Normal file
View File

@@ -0,0 +1,5 @@
// var test = await github.Repository.Release.Get(owner, repo, newRelease.TagName);
Console.WriteLine("false");
return 0;