✨ Conditionally Create Release (#8)
This commit is contained in:
@@ -37,6 +37,9 @@ EndProject
|
|||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpIDE.Godot", "src\SharpIDE.Godot\SharpIDE.Godot.csproj", "{D306410D-3A28-4F1B-A09B-CA10041A7C53}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpIDE.Godot", "src\SharpIDE.Godot\SharpIDE.Godot.csproj", "{D306410D-3A28-4F1B-A09B-CA10041A7C53}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iac", "iac", "{E239E6C6-8915-4F03-85B7-22AEAF281D14}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "iac", "iac", "{E239E6C6-8915-4F03-85B7-22AEAF281D14}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
iac\should-release.cs = iac\should-release.cs
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deploy", "iac\Deploy\Deploy.csproj", "{52CD8910-88A4-4978-B107-C7B6C7FC3557}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deploy", "iac\Deploy\Deploy.csproj", "{52CD8910-88A4-4978-B107-C7B6C7FC3557}"
|
||||||
EndProject
|
EndProject
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ public class CreateGithubRelease(IPipelineContext pipelineContext) : IStep
|
|||||||
var credentials = new Credentials(token);
|
var credentials = new Credentials(token);
|
||||||
github.Credentials = credentials;
|
github.Credentials = credentials;
|
||||||
|
|
||||||
var version = NuGetVersion.Parse("0.1.1");
|
var versionFile = await PipelineFileHelper.GitRootDirectory.GetFile("./src/SharpIDE.Godot/version.txt");
|
||||||
|
if (versionFile.Exists is false) throw new FileNotFoundException(versionFile.FullName);
|
||||||
|
var versionText = await File.ReadAllTextAsync(versionFile.FullName, cancellationToken);
|
||||||
|
|
||||||
|
var version = NuGetVersion.Parse(versionText);
|
||||||
var versionString = version.ToNormalizedString();
|
var versionString = version.ToNormalizedString();
|
||||||
var releaseTag = $"v{versionString}";
|
var releaseTag = $"v{versionString}";
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,50 @@
|
|||||||
|
#:package Octokit
|
||||||
|
#:package NuGet.Versioning
|
||||||
|
using Octokit;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
|
||||||
|
var versionFile = new FileInfo(Path.Combine(GetGitRootPath(), "src", "SharpIDE.Godot", "version.txt"));
|
||||||
|
if (versionFile.Exists is false) throw new FileNotFoundException(versionFile.FullName);
|
||||||
|
var versionText = await File.ReadAllTextAsync(versionFile.FullName);
|
||||||
|
|
||||||
// var test = await github.Repository.Release.Get(owner, repo, newRelease.TagName);
|
var version = NuGetVersion.Parse(versionText);
|
||||||
Console.WriteLine("false");
|
var versionString = version.ToNormalizedString();
|
||||||
return 0;
|
var releaseTag = $"v{versionString}";
|
||||||
|
|
||||||
|
var github = new GitHubClient(new ProductHeaderValue("SharpIDE-CI"));
|
||||||
|
var owner = "MattParkerDev";
|
||||||
|
var repo = "SharpIDE";
|
||||||
|
var release = await GetReleaseOrNull();
|
||||||
|
|
||||||
|
var resultString = release is null ? "true" : "false";
|
||||||
|
Console.WriteLine(resultString);
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
async Task<Release?> GetReleaseOrNull()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var release = await github.Repository.Release.Get(owner, repo, releaseTag);
|
||||||
|
return release;
|
||||||
|
}
|
||||||
|
catch (NotFoundException)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetGitRootPath()
|
||||||
|
{
|
||||||
|
var currentDirectory = Directory.GetCurrentDirectory();
|
||||||
|
var gitRoot = currentDirectory;
|
||||||
|
while (!Directory.Exists(Path.Combine(gitRoot, ".git")))
|
||||||
|
{
|
||||||
|
gitRoot = Path.GetDirectoryName(gitRoot); // parent directory
|
||||||
|
if (string.IsNullOrWhiteSpace(gitRoot))
|
||||||
|
{
|
||||||
|
throw new Exception("Could not find git root");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gitRoot;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
using FileAccess = Godot.FileAccess;
|
||||||
|
|
||||||
namespace SharpIDE.Godot.Features.SlnPicker;
|
namespace SharpIDE.Godot.Features.SlnPicker;
|
||||||
|
|
||||||
@@ -8,6 +10,8 @@ public partial class SlnPicker : Control
|
|||||||
private FileDialog _fileDialog = null!;
|
private FileDialog _fileDialog = null!;
|
||||||
private Button _openSlnButton = null!;
|
private Button _openSlnButton = null!;
|
||||||
private VBoxContainer _previousSlnsVBoxContainer = null!;
|
private VBoxContainer _previousSlnsVBoxContainer = null!;
|
||||||
|
private Label _versionLabel = null!;
|
||||||
|
private static NuGetVersion? _version;
|
||||||
|
|
||||||
private PackedScene _previousSlnEntryScene = ResourceLoader.Load<PackedScene>("res://Features/SlnPicker/PreviousSlnEntry.tscn");
|
private PackedScene _previousSlnEntryScene = ResourceLoader.Load<PackedScene>("res://Features/SlnPicker/PreviousSlnEntry.tscn");
|
||||||
|
|
||||||
@@ -21,12 +25,19 @@ public partial class SlnPicker : Control
|
|||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_previousSlnsVBoxContainer = GetNode<VBoxContainer>("%PreviousSlnsVBoxContainer");
|
_previousSlnsVBoxContainer = GetNode<VBoxContainer>("%PreviousSlnsVBoxContainer");
|
||||||
|
_versionLabel = GetNode<Label>("%VersionLabel");
|
||||||
_fileDialog = GetNode<FileDialog>("%FileDialog");
|
_fileDialog = GetNode<FileDialog>("%FileDialog");
|
||||||
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
_openSlnButton = GetNode<Button>("%OpenSlnButton");
|
||||||
_openSlnButton.Pressed += () => _fileDialog.PopupCentered();
|
_openSlnButton.Pressed += () => _fileDialog.PopupCentered();
|
||||||
var windowParent = GetParentOrNull<Window>();
|
var windowParent = GetParentOrNull<Window>();
|
||||||
_fileDialog.FileSelected += path => _tcs.SetResult(path);
|
_fileDialog.FileSelected += path => _tcs.SetResult(path);
|
||||||
windowParent?.CloseRequested += () => _tcs.SetResult(null);
|
windowParent?.CloseRequested += () => _tcs.SetResult(null);
|
||||||
|
if (_version is null)
|
||||||
|
{
|
||||||
|
var version = FileAccess.GetFileAsString("res://version.txt").Trim();
|
||||||
|
_version = NuGetVersion.Parse(version);
|
||||||
|
}
|
||||||
|
_versionLabel.Text = $"v{_version.ToNormalizedString()}";
|
||||||
if (Singletons.AppState.IdeSettings.AutoOpenLastSolution && GetParent() is not Window)
|
if (Singletons.AppState.IdeSettings.AutoOpenLastSolution && GetParent() is not Window)
|
||||||
{
|
{
|
||||||
var lastSln = Singletons.AppState.RecentSlns.LastOrDefault();
|
var lastSln = Singletons.AppState.RecentSlns.LastOrDefault();
|
||||||
|
|||||||
@@ -65,7 +65,8 @@ alignment = 1
|
|||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
text = "SharpIDE"
|
text = "SharpIDE"
|
||||||
|
|
||||||
[node name="Label2" type="Label" parent="VSplitContainer/Panel2/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
|
[node name="VersionLabel" type="Label" parent="VSplitContainer/Panel2/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_colors/font_color = Color(0.5689727, 0.56897277, 0.5689727, 1)
|
theme_override_colors/font_color = Color(0.5689727, 0.56897277, 0.5689727, 1)
|
||||||
text = "v0.1.2"
|
text = "v0.1.2"
|
||||||
|
|||||||
1
src/SharpIDE.Godot/version.txt
Normal file
1
src/SharpIDE.Godot/version.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
0.1.2
|
||||||
Reference in New Issue
Block a user