Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Apr 9, 2024
1 parent 7e38b66 commit c74ec5c
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 10 deletions.
4 changes: 3 additions & 1 deletion KitopiaAvalonia/KitopiaAvalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
<SatelliteResourceLanguages>none</SatelliteResourceLanguages>
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>

<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<DebugType Condition="'$(Configuration)' == 'Release'">none</DebugType>
<Version>0.0.2.037</Version>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="Assets\FluentSystemIcons-Filled.ttf"/>
Expand Down
17 changes: 17 additions & 0 deletions NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="avalonia-nightly" value="https://nuget-feed-all.avaloniaui.net/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="False" />
</packageManagement>
</configuration>
122 changes: 113 additions & 9 deletions build/Build.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using Microsoft.Build.Construction;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Utilities.Collections;
using Octokit;
using Serilog;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using Project = Nuke.Common.ProjectModel.Project;

[GitHubActions(
"continuous",
GitHubActionsImage.WindowsLatest,
On = new[] { GitHubActionsTrigger.Push },

ImportSecrets = new[] { nameof(GitHubToken) },
InvokedTargets = new[] { nameof(Compile) })]
class Build : NukeBuild
{
Expand All @@ -35,30 +42,127 @@ class Build : NukeBuild

[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;

[Parameter][Secret]readonly string GitHubToken;
Project AvaloniaProject => Solution.GetProject("KitopiaAvalonia");
Target Clean => _ => _
.Before(Restore)
.Executes(() =>
{
});


Target Restore => _ => _
.Executes(() =>
{
Log.Debug( "Restoring solution {0}", Solution);
Log.Debug("Restoring project {0}", AvaloniaProject);

DotNetRestore(c => new DotNetRestoreSettings()
.SetProjectFile(AvaloniaProject.Path));

DotNetRestore(c => new DotNetRestoreSettings()
.SetProjectFile("KitopiaEx"));

});

Target Compile => _ => _
.DependsOn(Restore)
.Executes(() =>
{
DotNetBuild(c => new DotNetBuildSettings()
.SetProjectFile(AvaloniaProject.Path));
// DotNetBuild(c =>
// {
// return new DotNetBuildSettings()
// .SetProjectFile(AvaloniaProject.Path)
// .SetOutputDirectory(RootDirectory / "output");
// });
});





Target Pack => _ => _
.OnlyWhenDynamic(() =>
{
var gitRepository = GitRepository.FromUrl("https://github.com/MakesYT/Kitopia");
var result = GitHubTasks.GetLatestRelease(gitRepository,true).Result;
Log.Debug("Packing project {0}", AvaloniaProject);
Log.Debug("GitHubName {0}", gitRepository.GetGitHubName());
var _gitHubClient = new GitHubClient(new ProductHeaderValue("Kitopia"))
{
Credentials = new Credentials(GitHubToken)
};
var readOnlyList = _gitHubClient.Repository.GetAllTags(gitRepository.GetGitHubOwner(), gitRepository.GetGitHubName()).Result;
if (readOnlyList.Any(e=>e.Name==AvaloniaProject.GetProperty("Version")))
{
return false;
}
return true;
})
.DependsOn(Compile)
.Executes(() =>
{
var rootDirectory = RootDirectory / "Publish";
rootDirectory.DeleteDirectory();
DotNetPublish(c => new DotNetPublishSettings()
.SetProject("KitopiaEx")
.SetOutput(RootDirectory / "Publish" / "plugins" / "KitopiaEx")
.SetRuntime( "win-x64")
.SetFramework("net8.0")
.SetConfiguration("Release")
.SetSelfContained(false)
);
DotNetPublish(c => new DotNetPublishSettings()
.SetProject(AvaloniaProject.Name)
.SetOutput(RootDirectory / "Publish")
.SetPublishSingleFile(true)

.SetRuntime( "win-x64")
.SetFramework("net8.0-windows10.0.17763.0")
.SetConfiguration("Release")
.SetSelfContained(false)
);

var gitRepository = GitRepository.FromUrl("https://github.com/MakesYT/Kitopia");
var result = GitHubTasks.GetLatestRelease(gitRepository,true).Result;
Log.Debug("Packing project {0}", AvaloniaProject);
Log.Debug("GitHubName {0}", gitRepository.GetGitHubName());
var _gitHubClient = new GitHubClient(new ProductHeaderValue("Kitopia"))
{
Credentials = new Credentials(GitHubToken)
};
foreach (var absolutePath in rootDirectory.GetFiles())
{
if (absolutePath.Extension is ".pdb" or ".xml")
{
absolutePath.DeleteFile();
}
}

var archiveFile = RootDirectory / "Kitopia"+AvaloniaProject.GetProperty("Version")+".zip";
archiveFile.DeleteFile();
rootDirectory.ZipTo(archiveFile);
var newRelease = new NewRelease(AvaloniaProject.GetProperty("Version"))
{
Name = "Kitopia",
Prerelease = true,
Draft = true,

};

var release = _gitHubClient.Repository.Release.Create(gitRepository.GetGitHubOwner(), gitRepository.GetGitHubName(),
newRelease).Result;
using var artifactStream = File.OpenRead(archiveFile);
var fileName = Path.GetFileName( "Kitopia"+AvaloniaProject.GetProperty("Version")+".zip");
var assetUpload = new ReleaseAssetUpload
{
FileName = fileName,
ContentType = "application/octet-stream",
RawData = artifactStream,
};
_gitHubClient.Repository.Release.UploadAsset(release,assetUpload).Wait();
Log.Debug(result);
}
);
Target Clean => _ => _
.DependsOn(Pack)
.Executes(() =>
{

});
}

0 comments on commit c74ec5c

Please sign in to comment.