Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Killers0992 committed Nov 16, 2024
1 parent 9a8800c commit 8509bce
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 31 deletions.
4 changes: 2 additions & 2 deletions XProxy.BuildListing/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build-env
WORKDIR /app

COPY . ./

RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/runtime:7.0
FROM mcr.microsoft.com/dotnet/runtime:9.0
WORKDIR /app

COPY --from=build-env /app/out .
Expand Down
27 changes: 27 additions & 0 deletions XProxy.BuildListing/Models/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Newtonsoft.Json;

namespace XProxy.Models
{
public class BuildInfo
{
private Version _parsedVersion;

[JsonIgnore]
public Version ParsedVersion
{
get
{
if (_parsedVersion == null)
System.Version.TryParse(Version, out _parsedVersion);

return _parsedVersion;
}
}

public string Version { get; set; } = "0.0.0";
public string[] SupportedGameVersions { get; set; } = new string[0];
public string[] Changelogs { get; set; } = new string[0];
public string CoreUrl { get; set; }
public string DependenciesUrl { get; set; }
}
}
9 changes: 0 additions & 9 deletions XProxy.BuildListing/XProxy.BuildListing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\XProxy\Models\BuildInfo.cs" Link="Models\BuildInfo.cs" />
<Compile Include="..\XProxy\Models\BuildsListing.cs" Link="Models\BuildsListing.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="McMaster.Extensions.Hosting.CommandLine" Version="4.1.1" />
Expand All @@ -21,8 +16,4 @@
<PackageReference Include="Octokit" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions XProxy.BuildRelease/Models/BuildInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Newtonsoft.Json;

namespace XProxy.Models
{
public class BuildInfo
{
private Version _parsedVersion;

[JsonIgnore]
public Version ParsedVersion
{
get
{
if (_parsedVersion == null)
System.Version.TryParse(Version, out _parsedVersion);

return _parsedVersion;
}
}

public string Version { get; set; } = "0.0.0";
public string[] SupportedGameVersions { get; set; } = new string[0];
public string[] Changelogs { get; set; } = new string[0];
public string CoreUrl { get; set; }
public string DependenciesUrl { get; set; }
}
}
25 changes: 17 additions & 8 deletions XProxy.BuildRelease/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using System.Reflection;
using XProxy.Core;
using XProxy.Models;

await Host.CreateDefaultBuilder()
Expand Down Expand Up @@ -50,7 +49,7 @@ public async Task<int> OnExecute(IConsole console)

string targetCoreLocation = Path.Combine(MainPath, "XProxy.Core.dll");

Assembly.LoadFrom(targetCoreLocation);
var coreAssembly = Assembly.LoadFrom(targetCoreLocation);

File.Move(coreFile, targetCoreLocation);

Expand Down Expand Up @@ -88,16 +87,26 @@ public async Task<int> OnExecute(IConsole console)

console.WriteLine($" [INFO] Archive dependencies.zip created");

var type = coreAssembly.GetType("XProxy.Core.BuildInformation");

FieldInfo textVersion = type.GetField("VersionText", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo supportedGameVersions = type.GetField("SupportedGameVersions", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo ChangelogsText = type.GetField("Changelogs", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

string version = (string) textVersion.GetValue(null);
string[] changelogs = (string[])ChangelogsText.GetValue(null);
string[] versions = (string[])supportedGameVersions.GetValue(null);

BuildInfo bInfo = new BuildInfo()
{
DependenciesUrl = $"https://github.com/Killers0992/XProxy/releases/download/{BuildInformation.VersionText}/dependencies.zip",
CoreUrl = $"https://github.com/Killers0992/XProxy/releases/download/{BuildInformation.VersionText}/XProxy.Core.dll",
Changelogs = BuildInformation.Changelogs,
Version = BuildInformation.VersionText,
SupportedGameVersions = BuildInformation.SupportedGameVersions,
DependenciesUrl = $"https://github.com/Killers0992/XProxy/releases/download/{version}/dependencies.zip",
CoreUrl = $"https://github.com/Killers0992/XProxy/releases/download/{version}/XProxy.Core.dll",
Changelogs = changelogs,
Version = version,
SupportedGameVersions = versions,
};

Environment.SetEnvironmentVariable("XPROXY_VERSION", BuildInformation.VersionText);
Environment.SetEnvironmentVariable("XPROXY_VERSION", version);

string serialized = JsonConvert.SerializeObject(bInfo, Formatting.Indented);

Expand Down
12 changes: 0 additions & 12 deletions XProxy.BuildRelease/XProxy.BuildRelease.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
<DockerDefaultTargetOS>Windows</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\XProxy\Models\BuildInfo.cs" Link="Models\BuildInfo.cs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="IronZIP" Version="2024.11.3" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
Expand All @@ -21,12 +17,4 @@
<PackageReference Include="Octokit" Version="13.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XProxy.Core\XProxy.Core.csproj" />
</ItemGroup>

<ItemGroup>
<Folder Include="Models\" />
</ItemGroup>

</Project>

0 comments on commit 8509bce

Please sign in to comment.