Add new version and changelog system

This commit is contained in:
Marcel Baumgartner 2023-06-11 20:59:20 +02:00
parent 0a1b93b8fb
commit 9a262d1396
9 changed files with 210 additions and 377 deletions

1
.gitignore vendored
View file

@ -42,3 +42,4 @@ Desktop.ini
storage/ storage/
Moonlight/publish.ps1 Moonlight/publish.ps1
Moonlight/version

View file

@ -1,11 +0,0 @@
namespace Moonlight.App.Services.Background;
public class UptimeService
{
public DateTime StartTimestamp { get; private set; }
public UptimeService()
{
StartTimestamp = DateTime.UtcNow;
}
}

View file

@ -0,0 +1,101 @@
using Logging.Net;
using Octokit;
using Repository = LibGit2Sharp.Repository;
namespace Moonlight.App.Services;
public class MoonlightService
{
private readonly ConfigService ConfigService;
public readonly DateTime StartTimestamp;
public readonly string AppVersion;
public readonly List<string[]> ChangeLog = new();
public MoonlightService(ConfigService configService)
{
ConfigService = configService;
StartTimestamp = DateTime.UtcNow;
if (File.Exists("version") && !ConfigService.DebugMode)
AppVersion = File.ReadAllText("version");
else if (ConfigService.DebugMode)
{
string repositoryPath = Path.GetFullPath("..");
using var repo = new Repository(repositoryPath);
var commit = repo.Head.Tip;
AppVersion = commit.Sha;
}
else
AppVersion = "unknown";
Task.Run(FetchChangeLog);
}
private async Task FetchChangeLog()
{
if(AppVersion == "unknown")
return;
if (ConfigService.DebugMode)
{
ChangeLog.Add(new[]
{
"Disabled",
"Fetching changelog from github is disabled in debug mode"
});
return;
}
try
{
var client = new GitHubClient(new ProductHeaderValue("Moonlight"));
var pullRequests = await client.PullRequest.GetAllForRepository("Moonlight-Panel", "Moonlight", new PullRequestRequest
{
State = ItemStateFilter.Closed,
SortDirection = SortDirection.Ascending,
SortProperty = PullRequestSort.Created
});
var groupedPullRequests = new Dictionary<DateTime, List<string>>();
foreach (var pullRequest in pullRequests)
{
if (pullRequest.MergedAt != null)
{
var date = pullRequest.MergedAt.Value.Date;
if (!groupedPullRequests.ContainsKey(date))
{
groupedPullRequests[date] = new List<string>();
}
groupedPullRequests[date].Add(pullRequest.Title);
}
}
int i = 1;
foreach (var group in groupedPullRequests)
{
var pullRequestsList = new List<string>();
var date = group.Key.ToString("dd.MM.yyyy");
pullRequestsList.Add($"Patch {i}, {date}");
foreach (var pullRequest in group.Value)
{
pullRequestsList.Add(pullRequest);
}
ChangeLog.Add(pullRequestsList.ToArray());
i++;
}
}
catch (Exception e)
{
Logger.Warn("Error fetching changelog");
Logger.Warn(e);
}
}
}

View file

@ -22,5 +22,6 @@ COPY --from=publish /app/publish .
RUN mkdir -p /app/storage RUN mkdir -p /app/storage
RUN touch /app/storage/donttriggeranyerrors RUN touch /app/storage/donttriggeranyerrors
RUN rm -r /app/storage/* RUN rm -r /app/storage/*
COPY version /app/version
COPY "Moonlight/defaultstorage" "/app/defaultstorage" COPY "Moonlight/defaultstorage" "/app/defaultstorage"
ENTRYPOINT ["dotnet", "Moonlight.dll"] ENTRYPOINT ["dotnet", "Moonlight.dll"]

View file

@ -24,6 +24,7 @@
<PackageReference Include="FluentFTP" Version="46.0.2" /> <PackageReference Include="FluentFTP" Version="46.0.2" />
<PackageReference Include="GravatarSharp.Core" Version="1.0.1.2" /> <PackageReference Include="GravatarSharp.Core" Version="1.0.1.2" />
<PackageReference Include="JWT" Version="10.0.2" /> <PackageReference Include="JWT" Version="10.0.2" />
<PackageReference Include="LibGit2Sharp" Version="0.27.2" />
<PackageReference Include="Logging.Net" Version="1.1.3" /> <PackageReference Include="Logging.Net" Version="1.1.3" />
<PackageReference Include="MailKit" Version="4.0.0" /> <PackageReference Include="MailKit" Version="4.0.0" />
<PackageReference Include="Mappy.Net" Version="1.0.2" /> <PackageReference Include="Mappy.Net" Version="1.0.2" />
@ -40,6 +41,7 @@
<PackageReference Include="MineStat" Version="3.1.1" /> <PackageReference Include="MineStat" Version="3.1.1" />
<PackageReference Include="MySqlBackup.NET" Version="2.3.8" /> <PackageReference Include="MySqlBackup.NET" Version="2.3.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3-beta1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3-beta1" />
<PackageReference Include="Octokit" Version="6.0.0" />
<PackageReference Include="Otp.NET" Version="1.3.0" /> <PackageReference Include="Otp.NET" Version="1.3.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" /> <PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="QRCoder" Version="1.4.3" /> <PackageReference Include="QRCoder" Version="1.4.3" />

View file

@ -34,9 +34,6 @@ namespace Moonlight
{ {
public class Program public class Program
{ {
// App version. Change for release
public static readonly string AppVersion = $"InDev {Formatter.FormatDateOnly(DateTime.Now.Date)}";
public static async Task Main(string[] args) public static async Task Main(string[] args)
{ {
Logger.UsedLogger = new CacheLogger(); Logger.UsedLogger = new CacheLogger();
@ -168,7 +165,9 @@ namespace Moonlight
builder.Services.AddSingleton<StatisticsCaptureService>(); builder.Services.AddSingleton<StatisticsCaptureService>();
builder.Services.AddSingleton<DiscordNotificationService>(); builder.Services.AddSingleton<DiscordNotificationService>();
builder.Services.AddSingleton<CleanupService>(); builder.Services.AddSingleton<CleanupService>();
builder.Services.AddSingleton<UptimeService>();
// Other
builder.Services.AddSingleton<MoonlightService>();
// Third party services // Third party services
builder.Services.AddBlazorTable(); builder.Services.AddBlazorTable();
@ -204,7 +203,8 @@ namespace Moonlight
_ = app.Services.GetRequiredService<DiscordBotService>(); _ = app.Services.GetRequiredService<DiscordBotService>();
_ = app.Services.GetRequiredService<StatisticsCaptureService>(); _ = app.Services.GetRequiredService<StatisticsCaptureService>();
_ = app.Services.GetRequiredService<DiscordNotificationService>(); _ = app.Services.GetRequiredService<DiscordNotificationService>();
_ = app.Services.GetRequiredService<UptimeService>();
_ = app.Services.GetRequiredService<MoonlightService>();
// Discord bot service // Discord bot service
//var discordBotService = app.Services.GetRequiredService<DiscordBotService>(); //var discordBotService = app.Services.GetRequiredService<DiscordBotService>();

View file

@ -1,18 +1,11 @@
{ {
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:26548",
"sslPort": 44339
}
},
"profiles": { "profiles": {
"Moonlight": { "Moonlight": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development",
"ML_DEBUG": "true"
}, },
"applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118", "applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118",
"dotnetRunMessages": true "dotnetRunMessages": true
@ -22,7 +15,8 @@
"launchBrowser": true, "launchBrowser": true,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"ML_SQL_DEBUG": "true" "ML_SQL_DEBUG": "true",
"ML_DEBUG": "true"
}, },
"applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118", "applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118",
"dotnetRunMessages": true "dotnetRunMessages": true
@ -32,17 +26,11 @@
"launchBrowser": false, "launchBrowser": false,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development", "ASPNETCORE_ENVIRONMENT": "Development",
"ML_SQL_DEBUG": "true" "ML_SQL_DEBUG": "true",
"ML_DEBUG": "true"
}, },
"applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118", "applicationUrl": "http://moonlight.testy:5118;https://localhost:7118;http://localhost:5118",
"dotnetRunMessages": true "dotnetRunMessages": true
},
"Docker": {
"commandName": "Docker",
"launchBrowser": false,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
"publishAllPorts": true,
"useSSL": true
} }
} }
} }

View file

@ -2,14 +2,15 @@
@using Moonlight.Shared.Components.Navigations @using Moonlight.Shared.Components.Navigations
@using Moonlight.App.Helpers @using Moonlight.App.Helpers
@using Moonlight.App.Services.Background @using Moonlight.App.Services
@inject HostSystemHelper HostSystemHelper @inject HostSystemHelper HostSystemHelper
@inject UptimeService UptimeService @inject MoonlightService MoonlightService
<OnlyAdmin> <OnlyAdmin>
<AdminSystemNavigation Index="0"/> <AdminSystemNavigation Index="0"/>
<LazyLoader Load="Load">
<div class="row"> <div class="row">
<div class="col-xxl-6 my-3"> <div class="col-xxl-6 my-3">
<div class="card"> <div class="card">
@ -21,7 +22,7 @@
<div class="card-body"> <div class="card-body">
<span class="fs-5"> <span class="fs-5">
<TL>You are running moonlight version</TL> <TL>You are running moonlight version</TL>
<span class="text-primary">@(Program.AppVersion)</span> <span class="text-primary">@(MoonlightService.AppVersion)</span>
</span> </span>
</div> </div>
</div> </div>
@ -83,11 +84,20 @@
<span class="fs-5"> <span class="fs-5">
<TL>Moonlight is since</TL> <TL>Moonlight is since</TL>
<span class="text-primary"> <span class="text-primary">
@(Formatter.FormatUptime(DateTime.UtcNow - UptimeService.StartTimestamp)) @(Formatter.FormatUptime(DateTime.UtcNow - MoonlightService.StartTimestamp))
</span> </span>
</span> </span>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</LazyLoader>
</OnlyAdmin> </OnlyAdmin>
@code
{
private Task Load(LazyLoader arg)
{
return Task.CompletedTask;
}
}

View file

@ -1,275 +1,16 @@
@page "/changelog" @page "/changelog"
@using Moonlight.App.Services
@inject MoonlightService MoonlightService
@{ @{
List<string[]> changelog = new List<string[]>
{
new[]
{
"Patch 1, 13.03.2023",
"Service manager"
},
new[]
{
"Patch 2, 14.03.2023",
"Added new image manager. CRUD implemeted"
},
new[]
{
"Patch 3, 20.03.2023",
"Ddos detection",
"Implemented server manager"
},
new[]
{
"Patch 4, 21.03.2023",
"Added user edit form. Fixed edit link"
},
new[]
{
"Patch 5, 24.03.2023",
"Update Discord Bot Branche",
"Removed discord id and discriminator. Fixed oauth2.",
"Updated discord bot branch",
"Updated smart form branch",
"Added smart form",
"Updating PleskIntegration branch",
"Revert \"Updating PleskIntegration branch\""
},
new[]
{
"Patch 6, 27.03.2023",
"Update Index.razor",
"User settings"
},
new[]
{
"Patch 7, 28.03.2023",
"Added form proccessing screen (not finished). Some ui changes. User m."
},
new[]
{
"Patch 8, 02.04.2023",
"Server manage enhancements",
"Cleanup system",
"Update WingsServerConverter.cs",
"Added quick create dropdown",
"fixed login form",
"Login form fix"
},
new[]
{
"Patch 9, 03.04.2023",
"Fixed cleanup",
"Added server reset setting",
"Totp",
"Update from upstream because of database models",
"Audit log",
"Audit log",
"Force password change",
"Support chat redesign",
"Subscriptions",
"Added server rename setting"
},
new[]
{
"Patch 10, 04.04.2023",
"Added server delete. Tweaked setting names",
"Added server node status screen check thingy",
"Update CacheLogger.cs",
"Update to upstream branch",
"Update View.razor",
"Update to upstream branch",
"Removed legacy aaPanel stuff",
"Update DesignFixes",
"Design fixes",
"Create Changelog.razor"
},
new[]
{
"Patch 11, 05.04.2023",
"Ftp file manager",
"Update to upstream branch",
"Added ActivityStatus"
},
new[]
{
"Patch 12, 06.04.2023",
"Domain overview",
"Plesk integration",
"Add websites to statistics branch",
"Removed legacy database ui",
"Replaced legacy dependency resolve with server service function for w.",
"masu is too stupid to use ulong",
"Statistic system",
"host file access + use in admin resource manager"
},
new[]
{
"Patch 13, 10.04.2023",
"Removed old typeahead. Added own solution. Lang file, notes",
"Implemented website order"
},
new[]
{
"Patch 14, 11.04.2023",
"Implemented domain order. Fixed some bugs"
},
new[]
{
"Patch 15, 12.04.2023",
"Implemented new soft error boundary crash handler",
"Added ip locate. Fixed oauth2 mail send. Fixed mail send when generat.",
"Implemented multi allocation",
"register",
"Fixed server lists",
"News page",
"Improved news system"
},
new[]
{
"Patch 16, 13.04.2023",
"domain view redesigned | fixed some masu at midnight",
"Persistent storage",
"Removed old file manager stuff",
"fixed design of delete button",
"redesigned shared domains screen | split in view/add"
},
new[]
{
"Patch 17, 14.04.2023",
"Removed legacy image tags",
"Fixed server deletion and creation allocation bugs"
},
new[]
{
"Patch 18, 15.04.2023",
"Update DiscordBot branch",
"Fix backup delete",
"Implemented default subscription",
"Implemented random loading message",
"Recode frontend js"
},
new[]
{
"Patch 19, 16.04.2023",
"Optimized allocation search. Added sql command log interception",
"Fixed my stupid mistakes",
"Implemented file view loading animation"
},
new[]
{
"Patch 20, 19.04.2023",
"Cloud panel interation"
},
new[]
{
"Patch 21, 20.04.2023",
"Removed legacy website",
"Added user change status try catch, implement logout. password change",
"Added admin check to sftp login system",
"Implemented new event system",
"Rewritten support chat backend. Added discord notifications"
},
new[]
{
"Patch 22, 21.04.2023",
"Removed old support system",
"Deleted old message system. Replaced it with new event system",
"Update ServerNavigation.razor",
"Switched from internal smtp client to MailKit. Added ssl config"
},
new[]
{
"Patch 23, 23.04.2023",
"Added missing refresh call",
"Added better reconnect screens",
"Removed useless logging. Switched to cache mode for support chat",
"Fixed statistics system"
},
new[]
{
"Patch 24, 24.04.2023",
"Add checking user status to login sequence where login form is currently",
"Added config reload button"
},
new[]
{
"Patch 25, 25.04.2023",
"Update Create.razor",
"Added server count for image overview",
"Implemented owner change option in admin ui"
},
new[]
{
"Patch 26, 26.04.2023",
"Image import export",
"Fixed import and export",
"Prevent message duplication with sender check",
"Implemented forge version switcher"
},
new[]
{
"Patch 27, 28.04.2023",
"Improved user details profile page",
"Implemented fabric version setting"
},
new[]
{
"Patch 28, 29.04.2023",
"update my DiscordBot branch",
"Revert \"update my DiscordBot branch\"",
"Discord bot",
"Update to upstream branch"
},
new[]
{
"Patch 29, 02.05.2023",
"Update Index.razor",
"Added multi line feature and file upload in the support chat"
},
new[]
{
"Patch 30, 04.05.2023",
"Implemented new rating system"
},
new[]
{
"Patch 31, 05.05.2023",
"Code cleanup",
"added version and main jar setting",
"fixed server settings design",
"dotnet runtime settings"
},
new[]
{
"Patch 32, 06.05.2023",
"file create"
},
new[]
{
"Patch 33, 17.05.2023",
"Added node selector for server create screen",
"Added website directory limit for website file manager",
"Added new screenhot service",
"Added node and image view to manager. Made the data handling smoother"
},
new[]
{
"Patch 34, 19.05.2023",
"Added recaptcha. Added recaptcha to register page",
"Implemented ip ban"
}
};
changelog.Reverse();
int i = 0; int i = 0;
} }
<div class="card card-docs flex-row-fluid mb-2"> <div class="card card-docs flex-row-fluid mb-2">
<div class="card-body fs-6 py-15 px-10 py-lg-15 px-lg-15 text-gray-700"> <div class="card-body fs-6 py-15 px-10 py-lg-15 px-lg-15 text-gray-700">
<div class="accordion accordion-flush accordion-icon-toggle" id="kt_accordion"> <div class="accordion accordion-flush accordion-icon-toggle" id="kt_accordion">
@foreach (var prt in changelog) @foreach (var prt in MoonlightService.ChangeLog.ToArray().Reverse())
{ {
i++; i++;
<div class="accordion-item mb-5"> <div class="accordion-item mb-5">