Add NuGet metadata to library and add two new workflows for master pull requests and releases on github

This commit is contained in:
Daniel Cronqvist 2024-08-27 22:31:48 +02:00
parent 30c0d22f93
commit 39b7625c23
5 changed files with 113 additions and 1 deletions

37
.github/workflows/master-pr.yml vendored Normal file
View file

@ -0,0 +1,37 @@
on:
pull_request:
branches:
- master
jobs:
check-pr-version:
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v3
- name: Get version from PR branch
id: pr_version
run: |
PR_VERSION=$(grep '<Version>' **/*.csproj | sed -E 's/.*<Version>(.*)<\/Version>.*/\1/')
echo "PR_VERSION=$PR_VERSION" >> $GITHUB_ENV
- name: Checkout master branch
run: |
git fetch origin master
git checkout origin/master
- name: Get version from master branch
id: master_version
run: |
MASTER_VERSION=$(grep '<Version>' **/*.csproj | sed -E 's/.*<Version>(.*)<\/Version>.*/\1/')
echo "MASTER_VERSION=$MASTER_VERSION" >> $GITHUB_ENV
- name: Compare versions
run: |
if [ "$(printf '%s\n' "$PR_VERSION" "$MASTER_VERSION" | sort -V | head -n1)" = "$PR_VERSION" ] && [ "$PR_VERSION" != "$MASTER_VERSION" ]; then
echo "Version in PR is not higher than master."
exit 1
else
echo "Version in PR is higher than master."
fi

30
.github/workflows/release-nuget.yml vendored Normal file
View file

@ -0,0 +1,30 @@
on:
release:
types: [published]
jobs:
release-nuget:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore src/DotTiled.sln
- name: Build
run: dotnet build --no-restore src/DotTiled.sln
- name: Test
run: dotnet test --no-build --verbosity normal src/DotTiled.sln
- name: Lint style
run: dotnet format style --verify-no-changes --verbosity diagnostic src/DotTiled.sln
- name: Lint analyzers
run: dotnet format analyzers --verify-no-changes --verbosity diagnostic src/DotTiled.sln
- name: Pack
run: make pack
- name: Publish to NuGet.org
run: |
dotnet nuget push ./nupkg/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate
dotnet nuget push ./nupkg/*.snupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate

21
LICENSE Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Daniel Cronqvist (daniel@dcronqvist.se)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -13,6 +13,9 @@ lint:
dotnet format style --verify-no-changes src/DotTiled.sln dotnet format style --verify-no-changes src/DotTiled.sln
dotnet format analyzers --verify-no-changes src/DotTiled.sln dotnet format analyzers --verify-no-changes src/DotTiled.sln
pack:
dotnet pack src/DotTiled/DotTiled.csproj -c Release -o ./nupkg -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
BENCHMARK_SOURCES = src/DotTiled.Benchmark/Program.cs src/DotTiled.Benchmark/DotTiled.Benchmark.csproj BENCHMARK_SOURCES = src/DotTiled.Benchmark/Program.cs src/DotTiled.Benchmark/DotTiled.Benchmark.csproj
BENCHMARK_OUTPUTDIR = src/DotTiled.Benchmark/BenchmarkDotNet.Artifacts BENCHMARK_OUTPUTDIR = src/DotTiled.Benchmark/BenchmarkDotNet.Artifacts
.PHONY: benchmark .PHONY: benchmark

View file

@ -6,4 +6,25 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<PackageId>DotTiled</PackageId>
<Authors>dcronqvist</Authors>
<Title>DotTiled</Title>
<Description>DotTiled is a general-purpose Tiled map parser for all your .NET needs.</Description>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/dcronqvist/DotTiled</RepositoryUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>gamedev;window;parser;tiled;mapeditor</PackageTags>
<PackageProjectUrl>https://github.com/dcronqvist/DotTiled</PackageProjectUrl>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Copyright>Copyright © 2024 dcronqvist</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<None Include="../../README.md" Pack="true" PackagePath="" />
<None Include="../../LICENSE" Pack="true" PackagePath="" />
</ItemGroup>
</Project> </Project>