diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml
index 9db28ef..3b18a85 100644
--- a/.github/workflows/create-release.yml
+++ b/.github/workflows/create-release.yml
@@ -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
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 85d9ad5..b6e30df 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -46,9 +46,11 @@
+
-
+
+
@@ -63,4 +65,4 @@
-
+
\ No newline at end of file
diff --git a/iac/Deploy/Deploy.csproj b/iac/Deploy/Deploy.csproj
index 81f1d98..ebbeab0 100644
--- a/iac/Deploy/Deploy.csproj
+++ b/iac/Deploy/Deploy.csproj
@@ -8,6 +8,8 @@
+
+
diff --git a/iac/Deploy/Program.cs b/iac/Deploy/Program.cs
index f3db885..89f9596 100644
--- a/iac/Deploy/Program.cs
+++ b/iac/Deploy/Program.cs
@@ -24,6 +24,7 @@ builder.Services.AddParallelPipelines(
builder.Services
.AddStep()
.AddStep()
+ .AddStep()
;
using var host = builder.Build();
diff --git a/iac/Deploy/Steps/CreateGithubRelease.cs b/iac/Deploy/Steps/CreateGithubRelease.cs
new file mode 100644
index 0000000..2085652
--- /dev/null
+++ b/iac/Deploy/Steps/CreateGithubRelease.cs
@@ -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]
+public class CreateGithubRelease(IPipelineContext pipelineContext) : IStep
+{
+ public async Task RunStep(CancellationToken cancellationToken)
+ {
+ var github = new GitHubClient(new ProductHeaderValue("SharpIDE-CI"));
+ var token = pipelineContext.Configuration.GetValue("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;
+ }
+}
diff --git a/iac/Deploy/Steps/CreateWindowsRelease.cs b/iac/Deploy/Steps/CreateWindowsRelease.cs
index 4c7e37d..0f6dd40 100644
--- a/iac/Deploy/Steps/CreateWindowsRelease.cs
+++ b/iac/Deploy/Steps/CreateWindowsRelease.cs
@@ -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];
}
}
diff --git a/iac/should-release.cs b/iac/should-release.cs
new file mode 100644
index 0000000..25c97a1
--- /dev/null
+++ b/iac/should-release.cs
@@ -0,0 +1,5 @@
+
+
+// var test = await github.Repository.Release.Get(owner, repo, newRelease.TagName);
+Console.WriteLine("false");
+return 0;
\ No newline at end of file