diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 9a867e9..ada6620 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,7 +1,7 @@ -name-template: 'v$RESOLVED_VERSION' +name-template: 'Release v$RESOLVED_VERSION' tag-template: 'v$RESOLVED_VERSION' template: | - # What's Changed + ## What's Changed $CHANGES categories: - title: 'Breaking' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..428aad5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: CI +on: + push: + paths: + - 'src/**' + - '.github/workflows/**' + pull_request: +jobs: + build: + if: ${{ false }} # disable for now + runs-on: ubuntu-latest + env: + SLN_FILE_NAME: Digitalroot.Valheim.PluginInfo.sln + NUGET_AUTH_TOKEN: ${{secrets.NUGET_PAT}} + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Install dotnet + uses: actions/setup-dotnet@v1 + with: + source-url: https://nuget.pkg.github.com/Digitalroot-Valheim/index.json + - name: Restore packages + run: dotnet restore src/${{ env.SLN_FILE_NAME }} --nologo + - name: Build + run: dotnet build src/${{ env.SLN_FILE_NAME }} -c Release --no-restore --nologo + - name: Test + run: dotnet test src/${{ env.SLN_FILE_NAME }} -c Release --no-build -l "trx;LogFileName=test-results.trx" --nologo + - uses: actions/upload-artifact@v2 + if: always() + with: + path: ./src/UnitTests/TestResults/test-results.trx + name: test-results + retention-days: 1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..cae8512 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +name: NuGet Package +on: + push: + branches: + - main # Default release branch + paths: + - 'src/**' + - '.github/workflows/**' +jobs: + deploy: + if: ${{ false }} # disable for now + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + env: + SLN_FILE_NAME: Digitalroot.Valheim.PluginInfo.sln + PROJ: Digitalroot.Valheim.PluginInfo + NUGET_AUTH_TOKEN: ${{secrets.NUGET_PAT}} + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true + DOTNET_CLI_TELEMETRY_OPTOUT: true + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-dotnet@v1.8.1 + with: + #dotnet-version: '3.1.x' # SDK Version to use. + source-url: https://nuget.pkg.github.com/Digitalroot-Valheim/index.json + - name: Check out repository code + uses: actions/checkout@v2 + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - name: Restore packages + run: dotnet restore src/${{ env.SLN_FILE_NAME }} --nologo + - name: Build + run: dotnet build src/${{ env.SLN_FILE_NAME }} -c Release --no-restore --nologo + - name: Test + run: dotnet test src/${{ env.SLN_FILE_NAME }} -c Release --no-build --nologo + - name: Create the package + run: dotnet pack src/${{ env.PROJ }}/${{ env.PROJ }}.csproj -c Release --no-restore --no-build --nologo + - name: Publish package to Digitalroot-Valheim nuget repository + run: dotnet nuget push src/${{ env.PROJ }}/bin/Release/*.nupkg --skip-duplicate diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 0000000..1fb7c26 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,21 @@ +name: 'Test Report' +on: + workflow_run: + workflows: ['CI'] # runs after CI workflow + types: + - completed +jobs: + report: + if: ${{ false }} # disable for now + runs-on: ubuntu-latest + steps: + - uses: dorny/test-reporter@v1 + with: + artifact: test-results # artifact name + name: NUnit Tests # Name of the check run which will be created + path: '*.trx' # Path to test results (inside artifact .zip) + reporter: dotnet-trx # Format of test results + path-replace-backslashes: 'true' + list-suites: 'all' + list-tests: 'failed' + max-annotations: '50' diff --git a/src/Digitalroot.Valheim.PluginInfo.sln b/src/Digitalroot.Valheim.PluginInfo.sln index 10ba9d1..de5fd9d 100644 --- a/src/Digitalroot.Valheim.PluginInfo.sln +++ b/src/Digitalroot.Valheim.PluginInfo.sln @@ -8,12 +8,23 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B6C936B0-4E6A-4AB8-A3FF-5AA2C1A0C59C}" ProjectSection(SolutionItems) = preProject ..\.gitignore = ..\.gitignore - ..\.github\workflows\drafter.yml = ..\.github\workflows\drafter.yml ..\LICENSE = ..\LICENSE ..\README.md = ..\README.md + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9}" + ProjectSection(SolutionItems) = preProject ..\.github\release-drafter.yml = ..\.github\release-drafter.yml EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{0B780DC6-CDC0-4FE8-93BD-2945C9B0B8A6}" + ProjectSection(SolutionItems) = preProject + ..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml + ..\.github\workflows\drafter.yml = ..\.github\workflows\drafter.yml + ..\.github\workflows\publish.yml = ..\.github\workflows\publish.yml + ..\.github\workflows\test-report.yml = ..\.github\workflows\test-report.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -28,6 +39,10 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9} = {B6C936B0-4E6A-4AB8-A3FF-5AA2C1A0C59C} + {0B780DC6-CDC0-4FE8-93BD-2945C9B0B8A6} = {89E8E94A-90F4-4FD3-B72F-C558A9ED8BF9} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {DBD9181E-33F5-4CBE-9C7D-06A9FDCEF711} EndGlobalSection diff --git a/src/Digitalroot.Valheim.PluginInfo/Digitalroot.Valheim.PluginInfo.csproj b/src/Digitalroot.Valheim.PluginInfo/Digitalroot.Valheim.PluginInfo.csproj index cb990d8..64ebaad 100644 --- a/src/Digitalroot.Valheim.PluginInfo/Digitalroot.Valheim.PluginInfo.csproj +++ b/src/Digitalroot.Valheim.PluginInfo/Digitalroot.Valheim.PluginInfo.csproj @@ -1,5 +1,5 @@  - + @@ -13,6 +13,7 @@ v4.6.2 512 true + latest @@ -87,8 +88,8 @@ ..\packages\Digitalroot.Valheim.Common.Json.1.0.2\lib\net462\Digitalroot.Valheim.Common.Json.dll - - ..\packages\Digitalroot.Valheim.Common.Log.1.0.4\lib\net462\Digitalroot.Valheim.Common.Log.dll + + ..\packages\Digitalroot.Valheim.Common.Log.1.1.4\lib\net462\Digitalroot.Valheim.Common.Log.dll ..\packages\fastJSON.2.4.0.4\lib\net40\fastJSON.dll diff --git a/src/Digitalroot.Valheim.PluginInfo/Main.cs b/src/Digitalroot.Valheim.PluginInfo/Main.cs index 5bc7cc9..d256d11 100644 --- a/src/Digitalroot.Valheim.PluginInfo/Main.cs +++ b/src/Digitalroot.Valheim.PluginInfo/Main.cs @@ -8,22 +8,30 @@ namespace Digitalroot.Valheim.PluginInfo { [BepInPlugin(Guid, Name, Version)] - public class Main : BaseUnityPlugin + public class Main : BaseUnityPlugin, ITraceableLogging { - public const string Version = "1.0.3"; - public const string Name = "Digitalroot Plug-in Info"; - private const string Guid = "digitalroot.mods.plugininfo"; - public const string Namespace = nameof(PluginInfo); private Harmony _harmony; + public const string Version = "1.1.0"; + public const string Name = "Digitalroot Plug-in Info"; + // ReSharper disable once MemberCanBePrivate.Global + public const string Guid = "digitalroot.mods.plugininfo"; + public const string Namespace = "Digitalroot.Valheim." + nameof(PluginInfo); public static Main Instance; + #region Implementation of ITraceableLogging + + /// + public string Source => Namespace; + + #endregion + public Main() { #if DEBUG - Log.EnableTrace(); + Log.RegisterSource(this, true); #endif - Log.Trace($"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()"); + Log.Trace(this, $"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()"); Instance = this; } @@ -36,47 +44,47 @@ private void Awake() [UsedImplicitly] private void OnDestroy() { - Log.Trace($"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()"); + Log.Trace(this, $"{GetType().Namespace}.{GetType().Name}.{MethodBase.GetCurrentMethod().Name}()"); _harmony?.UnpatchSelf(); } public void OnFejdStartupStart() { - Log.Debug("******* [Digitalroot Plug-ins Loaded] *******"); + Log.Debug(this, "******* [Digitalroot Plug-ins Loaded] *******"); foreach (KeyValuePair pluginInfo in BepInEx.Bootstrap.Chainloader.PluginInfos) { - Log.Debug($"Key: {pluginInfo.Key}"); - Log.Debug($"Value: {pluginInfo.Value}"); - Log.Debug($"GUID: {pluginInfo.Value.Metadata.GUID}"); - Log.Debug($"Name: {pluginInfo.Value.Metadata.Name}"); - Log.Debug($"Version: {pluginInfo.Value.Metadata.Version}"); - Log.Debug($"Location: {pluginInfo.Value.Location}"); + Log.Debug(this, $"Key: {pluginInfo.Key}"); + Log.Debug(this, $"Value: {pluginInfo.Value}"); + Log.Debug(this, $"GUID: {pluginInfo.Value.Metadata.GUID}"); + Log.Debug(this, $"Name: {pluginInfo.Value.Metadata.Name}"); + Log.Debug(this, $"Version: {pluginInfo.Value.Metadata.Version}"); + Log.Debug(this, $"Location: {pluginInfo.Value.Location}"); - Log.Debug($"Dependencies:"); + Log.Debug(this, $"Dependencies:"); foreach (BepInDependency dependency in pluginInfo.Value.Dependencies) { - Log.Debug($"DependencyGUID: {dependency.DependencyGUID}"); - Log.Debug($"Flags: {dependency.Flags}"); - Log.Debug($"MinimumVersion: {dependency.MinimumVersion}"); + Log.Debug(this, $"DependencyGUID: {dependency.DependencyGUID}"); + Log.Debug(this, $"Flags: {dependency.Flags}"); + Log.Debug(this, $"MinimumVersion: {dependency.MinimumVersion}"); } - Log.Debug($"Incompatibilities:"); + Log.Debug(this, $"Incompatibilities:"); foreach (BepInIncompatibility incompatibility in pluginInfo.Value.Incompatibilities) { - Log.Debug($"DependencyGUID: {incompatibility.IncompatibilityGUID}"); + Log.Debug(this, $"DependencyGUID: {incompatibility.IncompatibilityGUID}"); } - Log.Debug($"Instance: {pluginInfo.Value.Instance}"); - Log.Debug($"***************************************"); + Log.Debug(this, $"Instance: {pluginInfo.Value.Instance}"); + Log.Debug(this, $"***************************************"); } - Log.Debug($"DependencyErrors"); + Log.Debug(this, $"DependencyErrors"); foreach (string dependencyError in BepInEx.Bootstrap.Chainloader.DependencyErrors) { - Log.Debug($"{dependencyError}"); + Log.Debug(this, $"{dependencyError}"); } - Log.Debug($"***************************************"); + Log.Debug(this, $"***************************************"); } } } diff --git a/src/Digitalroot.Valheim.PluginInfo/Patch.cs b/src/Digitalroot.Valheim.PluginInfo/Patch.cs index a652e50..f7c1a10 100644 --- a/src/Digitalroot.Valheim.PluginInfo/Patch.cs +++ b/src/Digitalroot.Valheim.PluginInfo/Patch.cs @@ -19,13 +19,13 @@ public static void Postfix() { try { - Log.Trace($"{Main.Namespace}.{MethodBase.GetCurrentMethod().DeclaringType?.Name}.{MethodBase.GetCurrentMethod().Name}"); + Log.Trace(Main.Instance, $"{Main.Namespace}.{MethodBase.GetCurrentMethod().DeclaringType?.Name}.{MethodBase.GetCurrentMethod().Name}"); Main.Instance.OnFejdStartupStart(); } catch (Exception e) { - Log.Error(e); + Log.Error(Main.Instance, e); } } } diff --git a/src/Digitalroot.Valheim.PluginInfo/packages.config b/src/Digitalroot.Valheim.PluginInfo/packages.config index 9dd9a95..b5c5dbd 100644 --- a/src/Digitalroot.Valheim.PluginInfo/packages.config +++ b/src/Digitalroot.Valheim.PluginInfo/packages.config @@ -2,7 +2,7 @@ - +