Skip to content

Commit e28688c

Browse files
authored
Merge pull request #5 from samyycX/beta
2 parents fa09a2c + 5208115 commit e28688c

File tree

10 files changed

+131
-76
lines changed

10 files changed

+131
-76
lines changed

.github/workflows/build.yml

Lines changed: 88 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
name: Build
22

3-
on: [push, workflow_dispatch]
3+
on: [push, workflow_dispatch, pull_request]
44

55
env:
66
XMAKE_ROOT: y
77

8+
permissions:
9+
contents: write
10+
811
jobs:
912
versioning:
1013
runs-on: ubuntu-latest
1114
outputs:
1215
fullSemVer: ${{ steps.version_step.outputs.fullSemVer }}
1316
semVer: ${{ steps.version_step.outputs.semVer }}
1417
informationalVersion: ${{ steps.version_step.outputs.informationalVersion }}
18+
preReleaseLabel: ${{ steps.version_step.outputs.preReleaseLabel }}
1519
steps:
1620
- name: Checkout repository and submodules
1721
uses: actions/checkout@v4
@@ -27,6 +31,8 @@ jobs:
2731
managed:
2832
needs: versioning
2933
runs-on: ubuntu-latest
34+
permissions:
35+
id-token: write
3036
steps:
3137
- name: Checkout repository and submodules
3238
uses: actions/checkout@v4
@@ -64,27 +70,14 @@ jobs:
6470
uses: xmake-io/github-action-setup-xmake@v1
6571
with:
6672
xmake-version: latest
67-
build-cache: true
68-
- name: Restore build cache
69-
id: restore-cache
70-
uses: actions/cache/restore@v4
71-
with:
72-
path: |
73-
build
74-
key: ${{ runner.os }}-build
73+
actions-cache-folder: '.xmake-cache'
74+
actions-cache-key: xmake-${{ runner.os }}
7575
- name: Build
7676
run: |
7777
xmake f --cc=gcc-14 --cxx=g++-14 -y
7878
xmake build -y
7979
env:
8080
SWIFTLY_VERSION: ${{ needs.versioning.outputs.fullSemVer }}
81-
- name: Save cache
82-
id: save-cache
83-
uses: actions/cache/save@v4
84-
with:
85-
path: |
86-
build
87-
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
8881
- name: Upload plugin as artifact
8982
uses: actions/upload-artifact@v4
9083
with:
@@ -104,27 +97,12 @@ jobs:
10497
uses: xmake-io/github-action-setup-xmake@v1
10598
with:
10699
xmake-version: latest
107-
build-cache: true
108-
- name: Restore build cache
109-
id: restore-cache
110-
uses: actions/cache/restore@v4
111-
with:
112-
path: |
113-
build
114-
key: ${{ runner.os }}-build
100+
actions-cache-key: xmake-${{ runner.os }}
115101
- name: Build
116102
run: |
117-
xmake f --ccache=y
118103
xmake build -y
119104
env:
120105
SWIFTLY_VERSION: ${{ needs.versioning.outputs.fullSemVer }}
121-
- name: Save cache
122-
id: save-cache
123-
uses: actions/cache/save@v4
124-
with:
125-
path: |
126-
build
127-
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
128106
- name: Upload plugin as artifact
129107
uses: actions/upload-artifact@v4
130108
with:
@@ -140,8 +118,8 @@ jobs:
140118
needs: [versioning, linux_core, windows_core, managed]
141119
runs-on: ubuntu-latest
142120
env:
143-
LINUX_FOLDER: swiftlys2-linux-${{ needs.versioning.outputs.fullSemVer }}
144-
WINDOWS_FOLDER: swiftlys2-windows-${{ needs.versioning.outputs.fullSemVer }}
121+
LINUX_FOLDER: swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}
122+
WINDOWS_FOLDER: swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}
145123
steps:
146124
- name: Download artifacts
147125
uses: actions/download-artifact@v4
@@ -157,7 +135,7 @@ jobs:
157135
- name: Download artifacts
158136
uses: actions/download-artifact@v4
159137
with:
160-
name: swiftlys2_windows
138+
name: swiftlys2_managed
161139
path: ./managed
162140
- name: Download runtimes
163141
run: |
@@ -185,12 +163,83 @@ jobs:
185163
cp -r linux-runtimes/content/ ${{ env.LINUX_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet
186164
cp -r windows-runtimes/content/ ${{ env.WINDOWS_FOLDER }}-with-runtimes/swiftlys2/bin/managed/dotnet
187165
166+
zip -r ${{ env.LINUX_FOLDER }}-with-runtimes.zip ${{ env.LINUX_FOLDER }}-with-runtimes
167+
zip -r ${{ env.WINDOWS_FOLDER }}-with-runtimes.zip ${{ env.WINDOWS_FOLDER }}-with-runtimes
168+
zip -r ${{ env.LINUX_FOLDER }}.zip ${{ env.LINUX_FOLDER }}
169+
zip -r ${{ env.WINDOWS_FOLDER }}.zip ${{ env.WINDOWS_FOLDER }}
170+
188171
- name: Upload package
189172
uses: actions/upload-artifact@v4
190173
with:
191174
name: swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
192175
path: |
193-
${{ env.LINUX_FOLDER }}
194-
${{ env.WINDOWS_FOLDER }}
195-
${{ env.LINUX_FOLDER }}-with-runtimes
196-
${{ env.WINDOWS_FOLDER }}-with-runtimes
176+
${{ env.LINUX_FOLDER }}.zip
177+
${{ env.WINDOWS_FOLDER }}.zip
178+
${{ env.LINUX_FOLDER }}-with-runtimes.zip
179+
${{ env.WINDOWS_FOLDER }}-with-runtimes.zip
180+
181+
releasing:
182+
if: ${{ github.event_name == 'push' }}
183+
needs: [versioning, packaging]
184+
runs-on: ubuntu-latest
185+
steps:
186+
- name: Checkout repository and submodules
187+
uses: actions/checkout@v4
188+
with:
189+
fetch-depth: 0
190+
- name: Create tag
191+
run: |
192+
TAG_NAME="v${{ needs.versioning.outputs.fullSemVer }}"
193+
MSG="Release v${{ needs.versioning.outputs.fullSemVer }}"
194+
195+
git config --global user.name "github-actions[bot]"
196+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
197+
198+
if git rev-parse -q --verify "refs/tags/$TAG_NAME" >/dev/null; then
199+
echo "Tag $TAG_NAME already exists"; exit 1
200+
fi
201+
git tag -a "$TAG_NAME" -m "${MSG}"
202+
git push origin "$TAG_NAME"
203+
204+
- name: Download artifacts
205+
uses: actions/download-artifact@v4
206+
with:
207+
name: swiftlys2-package-${{ needs.versioning.outputs.fullSemVer }}
208+
path: ./release
209+
210+
- name: Create release
211+
uses: softprops/action-gh-release@v2
212+
with:
213+
generate_release_notes: true
214+
files: |
215+
release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}.zip
216+
release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}.zip
217+
release/swiftlys2-linux-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
218+
release/swiftlys2-windows-v${{ needs.versioning.outputs.fullSemVer }}-with-runtimes.zip
219+
prerelease: ${{ needs.versioning.outputs.preReleaseLabel != '' }}
220+
tag_name: v${{ needs.versioning.outputs.fullSemVer }}
221+
name: Release v${{ needs.versioning.outputs.fullSemVer }}
222+
body: ${{ needs.versioning.outputs.fullSemVer }}
223+
nuget:
224+
if: ${{ github.event_name == 'push' && github.repository_owner == 'swiftly-solution' }}
225+
needs: [versioning, releasing]
226+
runs-on: ubuntu-latest
227+
steps:
228+
- name: Checkout repository and submodules
229+
uses: actions/checkout@v4
230+
with:
231+
fetch-depth: 0
232+
- name: Setup .NET
233+
uses: actions/setup-dotnet@v4
234+
with:
235+
dotnet-version: '8.0.x'
236+
- name: Login to NuGet
237+
uses: NuGet/login@v1
238+
id: login
239+
with:
240+
user: samyyc
241+
- name: Publish to nuget
242+
run: |
243+
cd managed
244+
dotnet pack --include-symbols --output nupkgs -c Release -p:Version=${{ needs.versioning.outputs.fullSemVer }}
245+
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
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
4+
<PackageId>SwiftlyS2.CS2.PluginTemplate</PackageId>
5+
<Authors>SwiftlyS2 Team</Authors>
6+
<Version>0.0.1</Version>
7+
<Description>This is a template for creating a SwiftlyS2 plugin.</Description>
8+
<TargetFramework>net8.0</TargetFramework>
59
<ImplicitUsings>enable</ImplicitUsings>
610
<Nullable>enable</Nullable>
711
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
@@ -13,13 +17,12 @@
1317
</PropertyGroup>
1418

1519
<ItemGroup>
16-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0-rc.1.25451.107" />
17-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="10.0.0-rc.1.25451.107" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.0-rc.1.25451.107" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.0-rc.1.25451.107" />
20-
<PackageReference Include="Microsoft.Extensions.Logging" Version="10.0.0-rc.1.25451.107" />
21-
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
22-
<ProjectReference Include="../managed.csproj" ExcludeAssets="all" />
20+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
21+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
22+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
23+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
24+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
25+
<PackageReference Include="SwiftlyS2.CS2" Version="0.0.4-beta.8" ExcludeAssets="runtime" PrivateAssets="all" />
2326
</ItemGroup>
2427

2528
<ItemGroup>
@@ -33,10 +36,7 @@
3336
<PublishFiles Include="$(PublishDir)**\*.*" />
3437
</ItemGroup>
3538

36-
<ZipDirectory
37-
SourceDirectory="$(PublishDir)"
38-
DestinationFile="$(OutputPath)../$(AssemblyName).zip"
39-
Overwrite="true" />
39+
<ZipDirectory SourceDirectory="$(PublishDir)" DestinationFile="$(OutputPath)../$(AssemblyName).zip" Overwrite="true" />
4040
</Target>
4141

4242
</Project>

managed/icon.png

44 KB
Loading

managed/managed.csproj

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
5+
<PackageId>SwiftlyS2.CS2</PackageId>
6+
<Authors>SwiftlyS2 Team</Authors>
7+
<PackageIcon>icon.png</PackageIcon>
8+
<PackageProjectUrl>https://github.com/swiftly-solution/swiftlys2</PackageProjectUrl>
9+
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
10+
11+
412
<OutputType>Library</OutputType>
513
<TargetFramework>net8.0</TargetFramework>
614
<ImplicitUsings>enable</ImplicitUsings>
@@ -11,7 +19,7 @@
1119
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1220
<BaseOutputPath>build\</BaseOutputPath>
1321
<OutputPath>$(BaseOutputPath)Release\SwiftlyS2</OutputPath>
14-
<AssemblyName>SwiftlyS2</AssemblyName>
22+
<AssemblyName>SwiftlyS2.CS2</AssemblyName>
1523
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
1624

1725
</PropertyGroup>
@@ -24,6 +32,10 @@
2432
<DebugType>portable</DebugType>
2533
</PropertyGroup>
2634

35+
<ItemGroup>
36+
<None Include="icon.png" Pack="true" PackagePath="\"/>
37+
</ItemGroup>
38+
2739
<ItemGroup>
2840
<PackageReference Include="Dapper" Version="2.1.66" />
2941
<PackageReference Include="McMaster.NETCore.Plugins" Version="2.0.0" />

managed/src/SwiftlyS2.Core/Modules/GameData/GameDataService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ internal class GameDataService : IGameDataService {
2525
public GameDataService(CoreContext context, MemoryService memoryService, ILogger<GameDataService> logger) {
2626
_Context = context;
2727

28-
var signaturePath = Path.Combine(_Context.BaseDirectory, "gamedata", "signatures.jsonc");
29-
var offsetPath = Path.Combine(_Context.BaseDirectory, "gamedata", "offsets.jsonc");
30-
var patchPath = Path.Combine(_Context.BaseDirectory, "gamedata", "patches.jsonc");
28+
var signaturePath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "signatures.jsonc");
29+
var offsetPath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "offsets.jsonc");
30+
var patchPath = Path.Combine(_Context.BaseDirectory, "resources", "gamedata", "patches.jsonc");
3131

3232
try {
3333

managed/src/SwiftlyS2.Core/Modules/Translations/TranslationService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ public TranslationService(ILogger<TranslationService> logger, CoreContext contex
1818
_Logger = logger;
1919
_Context = context;
2020

21-
var translationDir = Path.Combine(_Context.BaseDirectory, "translations");
22-
Console.WriteLine(translationDir);
21+
var translationDir = Path.Combine(_Context.BaseDirectory, "resources", "translations");
2322

2423
if (!Directory.Exists(translationDir)) {
2524
return;

managed/src/SwiftlyS2.Core/Services/PluginConfigurationService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public IPluginConfigurationService InitializeWithTemplate(string name, string te
4747
}
4848
File.Create(configPath).Close();
4949

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

5252
if (!File.Exists(templateAbsPath)) {
5353
throw new FileNotFoundException($"Template file not found: {templateAbsPath}");

managed/src/TestPlugin/TestPlugin.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,12 @@ public override void Load(bool hotReload) {
9696

9797
// Core.
9898

99-
Console.WriteLine(Core.Localizer["test"]);
100-
10199
int i = 0;
102100

103101
// var token2 = Core.Scheduler.Repeat(10, () => {
104102
// Console.WriteLine(Core.Engine.TickCount);
105103
// Console.WriteLine("TestPlugin Timer");
106104
// });
107-
108-
Core.Logger.LogInformation(Core.GameData.GetSignature("Test").ToString());
109-
110105
Core.Logger.LogInformation("TestPlugin loaded");
111106

112107
using var se = new SoundEvent();

managed/src/TestPlugin/TestPlugin.csproj

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="Dapper" Version="2.1.66" />
17-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
18-
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
19-
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
20-
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" />
21-
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
22-
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" />
23-
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
24-
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" />
25-
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
26-
<ProjectReference Include="..\..\managed.csproj" ExcludeAssets="all" />
17+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
18+
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
19+
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
20+
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
21+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
22+
<PackageReference Include="Microsoft.Extensions.Options" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
23+
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
24+
<PackageReference Include="NetEscapades.Configuration.Yaml" Version="3.1.0" ExcludeAssets="runtime" PrivateAssets="all" />
25+
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" ExcludeAssets="runtime" PrivateAssets="all" />
26+
<ProjectReference Include="..\..\managed.csproj" ExcludeAssets="runtime" PrivateAssets="all" />
2727
</ItemGroup>
2828

2929
<ItemGroup>

src/core/managed/host/host.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ bool InitializeHostFXR(std::string origin_path) {
8282

8383
params.dotnet_root = dotnet_path;
8484

85-
int returnCode = _initialize_for_runtime_config((widenedOriginPath + WIN_LIN(L"bin\\managed\\SwiftlyS2.runtimeconfig.json", "bin/managed/SwiftlyS2.runtimeconfig.json")).c_str(), &params, &fxrcxt);
85+
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);
8686
if (returnCode != 0) {
8787
_close(fxrcxt);
8888
return false;
@@ -107,8 +107,8 @@ bool InitializeDotNetAPI(void* scripting_table, int scripting_table_size) {
107107

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

114114
if (returnCode != 0 || (void*)custom_loader == nullptr) {

0 commit comments

Comments
 (0)