Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 88 additions & 39 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
name: Build

on: [push, workflow_dispatch]
on: [push, workflow_dispatch, pull_request]

env:
XMAKE_ROOT: y

permissions:
contents: write

jobs:
versioning:
runs-on: ubuntu-latest
outputs:
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
semVer: ${{ steps.version_step.outputs.semVer }}
informationalVersion: ${{ steps.version_step.outputs.informationalVersion }}
preReleaseLabel: ${{ steps.version_step.outputs.preReleaseLabel }}
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
Expand All @@ -27,6 +31,8 @@ jobs:
managed:
needs: versioning
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
Expand Down Expand Up @@ -64,27 +70,14 @@ jobs:
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
build-cache: true
- name: Restore build cache
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
build
key: ${{ runner.os }}-build
actions-cache-folder: '.xmake-cache'
actions-cache-key: xmake-${{ runner.os }}
- name: Build
run: |
xmake f --cc=gcc-14 --cxx=g++-14 -y
xmake build -y
env:
SWIFTLY_VERSION: ${{ needs.versioning.outputs.fullSemVer }}
- name: Save cache
id: save-cache
uses: actions/cache/save@v4
with:
path: |
build
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: Upload plugin as artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -104,27 +97,12 @@ jobs:
uses: xmake-io/github-action-setup-xmake@v1
with:
xmake-version: latest
build-cache: true
- name: Restore build cache
id: restore-cache
uses: actions/cache/restore@v4
with:
path: |
build
key: ${{ runner.os }}-build
actions-cache-key: xmake-${{ runner.os }}
- name: Build
run: |
xmake f --ccache=y
xmake build -y
env:
SWIFTLY_VERSION: ${{ needs.versioning.outputs.fullSemVer }}
- name: Save cache
id: save-cache
uses: actions/cache/save@v4
with:
path: |
build
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
- name: Upload plugin as artifact
uses: actions/upload-artifact@v4
with:
Expand All @@ -140,8 +118,8 @@ jobs:
needs: [versioning, linux_core, windows_core, managed]
runs-on: ubuntu-latest
env:
LINUX_FOLDER: swiftlys2-linux-${{ needs.versioning.outputs.fullSemVer }}
WINDOWS_FOLDER: swiftlys2-windows-${{ needs.versioning.outputs.fullSemVer }}
LINUX_FOLDER: swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}
WINDOWS_FOLDER: swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
Expand All @@ -157,7 +135,7 @@ jobs:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: swiftlys2_windows
name: swiftlys2_managed
path: ./managed
- name: Download runtimes
run: |
Expand Down Expand Up @@ -185,12 +163,83 @@ jobs:
cp -r linux-runtimes/content/ ${{ env.LINUX_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet
cp -r windows-runtimes/content/ ${{ env.WINDOWS_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet

zip -r ${{ env.LINUX_FOLDER }}-with-runtimes.zip ${{ env.LINUX_FOLDER }}-with-runtimes
zip -r ${{ env.WINDOWS_FOLDER }}-with-runtimes.zip ${{ env.WINDOWS_FOLDER }}-with-runtimes
zip -r ${{ env.LINUX_FOLDER }}.zip ${{ env.LINUX_FOLDER }}
zip -r ${{ env.WINDOWS_FOLDER }}.zip ${{ env.WINDOWS_FOLDER }}

- name: Upload package
uses: actions/upload-artifact@v4
with:
name: swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
path: |
${{ env.LINUX_FOLDER }}
${{ env.WINDOWS_FOLDER }}
${{ env.LINUX_FOLDER }}-with-runtimes
${{ env.WINDOWS_FOLDER }}-with-runtimes
${{ env.LINUX_FOLDER }}.zip
${{ env.WINDOWS_FOLDER }}.zip
${{ env.LINUX_FOLDER }}-with-runtimes.zip
${{ env.WINDOWS_FOLDER }}-with-runtimes.zip

releasing:
if: ${{ github.event_name == 'push' }}
needs: [versioning, packaging]
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create tag
run: |
TAG_NAME="v${{ needs.versioning.outputs.fullSemVer }}"
MSG="Release v${{ needs.versioning.outputs.fullSemVer }}"

git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
echo "Tag $TAG_NAME already exists"; exit 1
fi
git tag -a "$TAG_NAME" -m "${MSG}"
git push origin "$TAG_NAME"

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
path: ./release

- name: Create release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}.zip
release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}.zip
release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
prerelease: ${{ needs.versioning.outputs.preReleaseLabel != '' }}
tag_name: v${{ needs.versioning.outputs.fullSemVer }}
name: Release v${{ needs.versioning.outputs.fullSemVer }}
body: ${{ needs.versioning.outputs.fullSemVer }}
nuget:
if: ${{ github.event_name == 'push' && github.repository_owner == 'swiftly-solution' }}
needs: [versioning, releasing]
runs-on: ubuntu-latest
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Login to NuGet
uses: NuGet/login@v1
id: login
with:
user: samyyc
- name: Publish to nuget
run: |
cd managed
dotnet pack --include-symbols --output nupkgs -c Release -p:Version=${{ needs.versioning.outputs.fullSemVer }}
dotnet nuget push nupkgs/SwiftlyS2.CS2.${{ needs.versioning.outputs.fullSemVer }}.nupkg --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://nuget.org/api/v2/package
24 changes: 12 additions & 12 deletions managed/SwiftlyS2.PluginTemplate/SwiftlyS2.Plugin.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<PackageId>SwiftlyS2.CS2.PluginTemplate</PackageId>
<Authors>SwiftlyS2 Team</Authors>
<Version>0.0.1</Version>
<Description>This is a template for creating a SwiftlyS2 plugin.</Description>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -13,13 +17,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0-rc.1.25451.107" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<ProjectReference Include="../managed.csproj" ExcludeAssets="all" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="SwiftlyS2.CS2" Version="0.0.4-beta.8" ExcludeAssets="runtime" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand All @@ -33,10 +36,7 @@
<PublishFiles Include="$(PublishDir)**\*.*" />
</ItemGroup>

<ZipDirectory
SourceDirectory="$(PublishDir)"
DestinationFile="$(OutputPath)../$(AssemblyName).zip"
Overwrite="true" />
<ZipDirectory SourceDirectory="$(PublishDir)" DestinationFile="$(OutputPath)../$(AssemblyName).zip" Overwrite="true" />
</Target>

</Project>
Binary file added managed/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion managed/managed.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<PackageId>SwiftlyS2.CS2</PackageId>
<Authors>SwiftlyS2 Team</Authors>
<PackageIcon>icon.png</PackageIcon>
<PackageProjectUrl>https://github.com/swiftly-solution/swiftlys2</PackageProjectUrl>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>


<OutputType>Library</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -11,7 +19,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<BaseOutputPath>build\</BaseOutputPath>
<OutputPath>$(BaseOutputPath)Release\SwiftlyS2</OutputPath>
<AssemblyName>SwiftlyS2</AssemblyName>
<AssemblyName>SwiftlyS2.CS2</AssemblyName>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>

</PropertyGroup>
Expand All @@ -24,6 +32,10 @@
<DebugType>portable</DebugType>
</PropertyGroup>

<ItemGroup>
<None Include="icon.png" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="McMaster.NETCore.Plugins" Version="2.0.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ internal class GameDataService : IGameDataService {
public GameDataService(CoreContext context, MemoryService memoryService, ILogger<GameDataService> logger) {
_Context = context;

var signaturePath = Path.Combine(_Context.BaseDirectory, "gamedata", "signatures.jsonc");
var offsetPath = Path.Combine(_Context.BaseDirectory, "gamedata", "offsets.jsonc");
var patchPath = Path.Combine(_Context.BaseDirectory, "gamedata", "patches.jsonc");
var signaturePath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "signatures.jsonc");
var offsetPath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "offsets.jsonc");
var patchPath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "patches.jsonc");

try {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ public TranslationService(ILogger<TranslationService> logger, CoreContext contex
_Logger = logger;
_Context = context;

var translationDir = Path.Combine(_Context.BaseDirectory, "translations");
Console.WriteLine(translationDir);
var translationDir = Path.Combine(_Context.BaseDirectory, "resources", "translations");

if (!Directory.Exists(translationDir)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public IPluginConfigurationService InitializeWithTemplate(string name, string te
}
File.Create(configPath).Close();

var templateAbsPath = Path.Combine(_Id.BaseDirectory, "templates", templatePath);
var templateAbsPath = Path.Combine(_Id.BaseDirectory, "resources", "templates", templatePath);

if (!File.Exists(templateAbsPath)) {
throw new FileNotFoundException($"Template file not found: {templateAbsPath}");
Expand Down
5 changes: 0 additions & 5 deletions managed/src/TestPlugin/TestPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,12 @@ public override void Load(bool hotReload) {

// Core.

Console.WriteLine(Core.Localizer["test"]);

int i = 0;

// var token2 = Core.Scheduler.Repeat(10, () => {
// Console.WriteLine(Core.Engine.TickCount);
// Console.WriteLine("TestPlugin Timer");
// });

Core.Logger.LogInformation(Core.GameData.GetSignature("Test").ToString());

Core.Logger.LogInformation("TestPlugin loaded");

using var se = new SoundEvent();
Expand Down
20 changes: 10 additions & 10 deletions managed/src/TestPlugin/TestPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.66" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<ProjectReference Include="..\..\managed.csproj" ExcludeAssets="all" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" ExcludeAssets="runtime" PrivateAssets="all" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
<ProjectReference Include="..\..\managed.csproj" ExcludeAssets="runtime" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/core/managed/host/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool InitializeHostFXR(std::string origin_path) {

params.dotnet_root = dotnet_path;

int returnCode = _initialize_for_runtime_config((widenedOriginPath + WIN_LIN(L"bin\\managed\\SwiftlyS2.runtimeconfig.json", "bin/managed/SwiftlyS2.runtimeconfig.json")).c_str(), &params, &fxrcxt);
int returnCode = _initialize_for_runtime_config((widenedOriginPath + WIN_LIN(L"bin\\managed\\SwiftlyS2.CS2.runtimeconfig.json", "bin/managed/SwiftlyS2.CS2.runtimeconfig.json")).c_str(), &params, &fxrcxt);
if (returnCode != 0) {
_close(fxrcxt);
return false;
Expand All @@ -107,8 +107,8 @@ bool InitializeDotNetAPI(void* scripting_table, int scripting_table_size) {

if (custom_loader == nullptr) {
int returnCode = _load_assembly_and_get_function_pointer(
(widenedOriginPath + WIN_LIN(L"bin\\managed\\SwiftlyS2.dll", "bin/managed/SwiftlyS2.dll")).c_str(),
STR("SwiftlyS2.Entrypoint, SwiftlyS2"), STR("Start"), UNMANAGEDCALLERSONLY_METHOD, nullptr, (void**)&custom_loader
(widenedOriginPath + WIN_LIN(L"bin\\managed\\SwiftlyS2.CS2.dll", "bin/managed/SwiftlyS2.CS2.dll")).c_str(),
STR("SwiftlyS2.Entrypoint, SwiftlyS2.CS2"), STR("Start"), UNMANAGEDCALLERSONLY_METHOD, nullptr, (void**)&custom_loader
);

if (returnCode != 0 || (void*)custom_loader == nullptr) {
Expand Down
Loading