diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 12f1c8efa..cbfda9c8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,10 +1,13 @@ 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 @@ -12,6 +15,7 @@ jobs: 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 @@ -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 @@ -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: @@ -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: @@ -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 @@ -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: | @@ -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 \ No newline at end of file + ${{ 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 \ No newline at end of file diff --git a/managed/SwiftlyS2.PluginTemplate/SwiftlyS2.Plugin.csproj b/managed/SwiftlyS2.PluginTemplate/SwiftlyS2.Plugin.csproj index 34fba7507..e6ac4f202 100644 --- a/managed/SwiftlyS2.PluginTemplate/SwiftlyS2.Plugin.csproj +++ b/managed/SwiftlyS2.PluginTemplate/SwiftlyS2.Plugin.csproj @@ -1,7 +1,11 @@ - net10.0 + SwiftlyS2.CS2.PluginTemplate + SwiftlyS2 Team + 0.0.1 + This is a template for creating a SwiftlyS2 plugin. + net8.0 enable enable true @@ -13,13 +17,12 @@ - - - - - - - + + + + + + @@ -33,10 +36,7 @@ - + \ No newline at end of file diff --git a/managed/icon.png b/managed/icon.png new file mode 100644 index 000000000..9f4b5f235 Binary files /dev/null and b/managed/icon.png differ diff --git a/managed/managed.csproj b/managed/managed.csproj index 8fb191fe5..47fb92bcd 100644 --- a/managed/managed.csproj +++ b/managed/managed.csproj @@ -1,6 +1,14 @@  + + SwiftlyS2.CS2 + SwiftlyS2 Team + icon.png + https://github.com/swiftly-solution/swiftlys2 + GPL-3.0-or-later + + Library net8.0 enable @@ -11,7 +19,7 @@ false build\ $(BaseOutputPath)Release\SwiftlyS2 - SwiftlyS2 + SwiftlyS2.CS2 true @@ -24,6 +32,10 @@ portable + + + + diff --git a/managed/src/SwiftlyS2.Core/Modules/GameData/GameDataService.cs b/managed/src/SwiftlyS2.Core/Modules/GameData/GameDataService.cs index 872639c44..ecfad7c32 100644 --- a/managed/src/SwiftlyS2.Core/Modules/GameData/GameDataService.cs +++ b/managed/src/SwiftlyS2.Core/Modules/GameData/GameDataService.cs @@ -25,9 +25,9 @@ internal class GameDataService : IGameDataService { public GameDataService(CoreContext context, MemoryService memoryService, ILogger 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 { diff --git a/managed/src/SwiftlyS2.Core/Modules/Translations/TranslationService.cs b/managed/src/SwiftlyS2.Core/Modules/Translations/TranslationService.cs index 1d9f102c2..10bc90c62 100644 --- a/managed/src/SwiftlyS2.Core/Modules/Translations/TranslationService.cs +++ b/managed/src/SwiftlyS2.Core/Modules/Translations/TranslationService.cs @@ -18,8 +18,7 @@ public TranslationService(ILogger 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; diff --git a/managed/src/SwiftlyS2.Core/Services/PluginConfigurationService.cs b/managed/src/SwiftlyS2.Core/Services/PluginConfigurationService.cs index 0494b89cf..ac90ab9d0 100644 --- a/managed/src/SwiftlyS2.Core/Services/PluginConfigurationService.cs +++ b/managed/src/SwiftlyS2.Core/Services/PluginConfigurationService.cs @@ -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}"); diff --git a/managed/src/TestPlugin/TestPlugin.cs b/managed/src/TestPlugin/TestPlugin.cs index bbdc20ec4..2c12f6757 100644 --- a/managed/src/TestPlugin/TestPlugin.cs +++ b/managed/src/TestPlugin/TestPlugin.cs @@ -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(); diff --git a/managed/src/TestPlugin/TestPlugin.csproj b/managed/src/TestPlugin/TestPlugin.csproj index bf6af638e..00f578d5d 100644 --- a/managed/src/TestPlugin/TestPlugin.csproj +++ b/managed/src/TestPlugin/TestPlugin.csproj @@ -14,16 +14,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/src/core/managed/host/host.cpp b/src/core/managed/host/host.cpp index 3df8e7a84..bea6bd977 100644 --- a/src/core/managed/host/host.cpp +++ b/src/core/managed/host/host.cpp @@ -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(), ¶ms, &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(), ¶ms, &fxrcxt); if (returnCode != 0) { _close(fxrcxt); return false; @@ -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) {