✨ Create Release via GH Action v1 (#7)
This commit is contained in:
12
.github/workflows/create-release.yml
vendored
12
.github/workflows/create-release.yml
vendored
@@ -5,6 +5,9 @@ on:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write # Required to create releases
|
||||
|
||||
jobs:
|
||||
execute-parallel-pipeline:
|
||||
runs-on: ubuntu-latest
|
||||
@@ -16,5 +19,14 @@ jobs:
|
||||
version: 4.5.1
|
||||
use-dotnet: true
|
||||
include-templates: true
|
||||
- name: Determine If Release Necessary
|
||||
id: determine-if-release-necessary
|
||||
run: |
|
||||
SHOULD_RELEASE=$(dotnet ./iac/should-release.cs)
|
||||
echo "Command output: $SHOULD_RELEASE"
|
||||
echo "should_release=$SHOULD_RELEASE" >> $GITHUB_OUTPUT
|
||||
- name: Dotnet Run Pipeline
|
||||
if: steps.determine-if-release-necessary.outputs.should_release == 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: dotnet run -c Release --project ./iac/Deploy/Deploy.csproj
|
||||
|
||||
@@ -46,9 +46,11 @@
|
||||
<PackageVersion Include="MudBlazor" Version="8.14.0" />
|
||||
<PackageVersion Include="NuGet.ProjectModel" Version="7.1.0-preview.1.42" />
|
||||
<PackageVersion Include="NuGet.Protocol" Version="7.1.0-preview.1.42" />
|
||||
<PackageVersion Include="NuGet.Versioning" Version="7.1.0-preview.1.42" />
|
||||
<PackageVersion Include="ObservableCollections" Version="3.3.4" />
|
||||
<PackageVersion Include="ObservableCollections.R3" Version="3.3.4" />
|
||||
<PackageVersion Include="ParallelPipelines" Version="2.1.0" />
|
||||
<PackageVersion Include="Octokit" Version="14.0.0" />
|
||||
<PackageVersion Include="ParallelPipelines" Version="2.1.0" />
|
||||
<PackageVersion Include="Photino.Blazor" Version="4.0.13" />
|
||||
<PackageVersion Include="R3" Version="1.3.0" />
|
||||
<PackageVersion Include="XtermBlazor" Version="2.2.0" />
|
||||
@@ -63,4 +65,4 @@
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.ExternalAccess.Razor.Features" Version="5.3.0-1.25521.106" />
|
||||
<PackageVersion Include="Microsoft.CodeAnalysis.Remote.ServiceHub" Version="5.3.0-1.25521.106" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
@@ -8,6 +8,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NuGet.Versioning" />
|
||||
<PackageReference Include="Octokit" />
|
||||
<PackageReference Include="ParallelPipelines" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ builder.Services.AddParallelPipelines(
|
||||
builder.Services
|
||||
.AddStep<RestoreAndBuildStep>()
|
||||
.AddStep<CreateWindowsRelease>()
|
||||
.AddStep<CreateGithubRelease>()
|
||||
;
|
||||
|
||||
using var host = builder.Build();
|
||||
|
||||
48
iac/Deploy/Steps/CreateGithubRelease.cs
Normal file
48
iac/Deploy/Steps/CreateGithubRelease.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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
5
iac/should-release.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
// var test = await github.Repository.Release.Get(owner, repo, newRelease.TagName);
|
||||
Console.WriteLine("false");
|
||||
return 0;
|
||||
Reference in New Issue
Block a user