diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml new file mode 100644 index 0000000..98a2c1f --- /dev/null +++ b/.github/workflows/nuget.yml @@ -0,0 +1,101 @@ +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json +# Based on Gerald Barre's blog post: https://www.meziantou.net/publishing-a-nuget-package-following-best-practices-using-github.htm + +name: publish +on: + workflow_dispatch: # Allow running the workflow manually from the GitHub UI + release: + types: + - published # Run the workflow when a new GitHub release is published + +env: + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 + DOTNET_NOLOGO: true + NuGetDirectory: ${{ github.workspace}}/nuget + +defaults: + run: + shell: pwsh + +jobs: + create_nuget: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Get all history to allow automatic versioning using MinVer + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + # Create the NuGet package in the folder from the environment variable NuGetDirectory + - run: dotnet pack --configuration Release --output ${{ env.NuGetDirectory }} /p:ContinuousIntegrationBuild=true + + # Publish the NuGet package as an artifact, so they can be used in the following jobs + - uses: actions/upload-artifact@v3 + with: + name: nuget + if-no-files-found: error + retention-days: 7 + path: ${{ env.NuGetDirectory }}/*.nupkg + + validate_nuget: + runs-on: ubuntu-latest + needs: [ create_nuget ] + steps: + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET + uses: actions/setup-dotnet@v4 + + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@v3 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + - name: Install nuget validator + run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global + + # Validate metadata and content of the NuGet package + # https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab + # If some rules are not applicable, you can disable them + # using the --excluded-rules or --excluded-rule-ids option + - name: Validate package + run: meziantou.validate-nuget-package (Get-ChildItem "${{ env.NuGetDirectory }}/*.nupkg") + + run_test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + - name: Run tests + run: dotnet test --configuration Release + + deploy: + # Publish only when creating a GitHub Release + # https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository + # You can update this logic if you want to manage releases differently + if: github.event_name == 'release' + runs-on: ubuntu-latest + needs: [ validate_nuget, run_test ] + steps: + # Download the NuGet package created in the previous job + - uses: actions/download-artifact@v3 + with: + name: nuget + path: ${{ env.NuGetDirectory }} + + # Install the .NET SDK indicated in the global.json file + - name: Setup .NET Core + uses: actions/setup-dotnet@v4 + + # Publish all NuGet packages to NuGet.org + # Use --skip-duplicate to prevent errors if a package with the same version already exists. + # If you retry a failed workflow, already published packages will be skipped without error. + - name: Publish NuGet package + run: | + foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) { + dotnet nuget push $file --api-key "${{ secrets.NUGET_APIKEY }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + } diff --git a/DBCD.IO/Common/OrderedHashSet.cs b/DBCD.IO/Common/OrderedHashSet.cs index 6149ac8..5defe0f 100644 --- a/DBCD.IO/Common/OrderedHashSet.cs +++ b/DBCD.IO/Common/OrderedHashSet.cs @@ -351,7 +351,7 @@ bool ICollection.IsReadOnly } /// - /// Add item to this hashset. This is the explicit implementation of the ICollection + /// Add item to this hashset. This is the explicit implementation of the ICollection{T} /// interface. The other Add method returns bool indicating whether item was added. /// /// item to add @@ -454,10 +454,10 @@ private int InternalIndexOf(T item) } /// - /// Returns the zero-based index of the first occurrence of a value in the or in a portion of it. + /// Returns the zero-based index of the first occurrence of a value in the or in a portion of it. /// - /// The object to locate in the . - /// The zero-based index of the first occurrence of item within the range of elements in the that extends from index to the last element, if found; otherwise, -1. + /// The object to locate in the . + /// The zero-based index of the first occurrence of item within the range of elements in the that extends from index to the last element, if found; otherwise, -1. public int IndexOf(T item) => InternalIndexOf(item); /// @@ -972,7 +972,7 @@ private void IncreaseCapacity() /// Add item to this HashSet. Returns bool indicating whether item was added (won't be /// added if already present) /// - /// + /// /// true if added, false if already present public bool Add(T value) { diff --git a/DBCD.IO/DBCD.IO.csproj b/DBCD.IO/DBCD.IO.csproj index f14b92b..f2fe959 100644 --- a/DBCD.IO/DBCD.IO.csproj +++ b/DBCD.IO/DBCD.IO.csproj @@ -2,8 +2,6 @@ netstandard2.0;net6.0;net8.0 - latest - 2.0.0 diff --git a/DBCD.IO/Extensions.cs b/DBCD.IO/Extensions.cs index c1ff99b..b26a65c 100644 --- a/DBCD.IO/Extensions.cs +++ b/DBCD.IO/Extensions.cs @@ -58,9 +58,10 @@ public static T Read(this BinaryReader reader) where T : struct /// /// Reads a NUL-separated string table from the current stream /// - /// Size of the string table + /// BinaryReader instance + /// Size of the string table /// Use WDC2-style position-base table key numbering - /// Base offset to use for the string table keys + /// Base offset to use for the string table keys public static Dictionary ReadStringTable(this BinaryReader reader, int stringTableSize, int baseOffset = 0, bool usePos = false) { var StringTable = new Dictionary(stringTableSize / 0x20); diff --git a/DBCD/DBCD.csproj b/DBCD/DBCD.csproj index e66dd1b..482a890 100644 --- a/DBCD/DBCD.csproj +++ b/DBCD/DBCD.csproj @@ -2,8 +2,6 @@ netstandard2.0;net6.0;net8.0 - latest - 2.0.0 diff --git a/Directory.build.props b/Directory.build.props new file mode 100644 index 0000000..c7cf425 --- /dev/null +++ b/Directory.build.props @@ -0,0 +1,32 @@ + + + portable + latest + 2.0.0 + + + WoWDev + Library for reading/writing World of Warcraft's DBC/DB2 files + git + https://github.com/wowdev/DBCD.git + true + MIT + README.md + library,DBC,DB2,World of Warcraft + https://github.com/wowdev/DBCD + true + true + snupkg + true + + + True + $(NoWarn);CS1591 + + + + + + + + \ No newline at end of file diff --git a/Directory.build.targets b/Directory.build.targets new file mode 100644 index 0000000..012d6ab --- /dev/null +++ b/Directory.build.targets @@ -0,0 +1,11 @@ + + + + + $([System.IO.Path]::Combine('$(IntermediateOutputPath)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)')) + + + + + + \ No newline at end of file diff --git a/README.md b/README.md index 4f213e2..40cd14f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ C# library for reading and writing [DBC](https://wowdev.wiki/DBC)/[DB2](https:// - Experimental writing (`WDC3` works, the others likely will too but are largely untested with actual WoW clients). - Applying of hotfixes (DBCache.bin). +## Projects +### DBCD +Contains the glue between DBCD.IO, DBDefsLib and the providers. + +### DBCD.IO +Contains the actual reading and writing of DBC/DB2 files. + ## Limitations - _(Reading/Writing)_ Relies on [WoWDBDefs](https://github.com/wowdev/WoWDBDefs) (DBDs) for table structures, can not load tables without DBDs (yet). - _(Writing)_ Does not support writing out DB2s with multiple sections.