Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"GitVersion.Tool": {
"version": "6.3.0",
"commands": [
"dotnet-gitversion"
]
}
}
}
43 changes: 23 additions & 20 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@ name: Code Coverage

on:
push:
branches: [ main, develop ]
branches: [ "**" ] # Trigger on all branches
pull_request:
branches: [ main ]
branches: [ "main", "release/**" ] # Trigger on PRs to main and release branches

permissions:
contents: read
actions: read
checks: write

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed

- name: Setup .NET
uses: actions/setup-dotnet@v4
Expand All @@ -26,37 +33,33 @@ jobs:

- name: Run TUNIT tests with coverage
run: |
dotnet test ./tests --no-build --configuration Release \
--collect:"XPlat Code Coverage" \
--results-directory ./test-results \
--logger "trx;LogFileName=TestResults.trx" \
--logger "console;verbosity=detailed"

- name: Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool

- name: Generate coverage report
run: |
reportgenerator \
-reports:"./test-results/**/coverage.cobertura.xml" \
-targetdir:"./coverage-report" \
-reporttypes:"Html;Cobertura;MarkdownSummaryGithub"
dotnet test --no-build --configuration Release \
-- --report-trx --coverage \
--results-directory ./test-results
continue-on-error: true # Continue even if tests fail

- name: Generate Code Coverage Report
uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: '**/*.coverage'
targetdir: ./coverage-report
reporttypes: Html;Cobertura;MarkdownSummaryGithub

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: test-results
path: |
./test-results/**/*.trx
./coverage-report/**/*
**/*.trx
**/*.coverage

- name: Publish test results
uses: dorny/test-reporter@v1
if: always()
with:
name: Test Results
path: './test-results/**/*.trx'
path: '**/*.trx'
reporter: dotnet-trx

- name: Code Coverage Report
Expand Down
61 changes: 36 additions & 25 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,44 @@ on:
branches: [ release, release/* ] # Trigger on release branch(es)
workflow_dispatch: # Allows manual trigger from any branch

permissions:
contents: write
packages: write
pull-requests: read

jobs:
build-and-test:
runs-on: ubuntu-latest

outputs:
version: ${{ steps.nbgv.outputs.SemVer2 }}
simple-version: ${{ steps.nbgv.outputs.SimpleVersion }}
version: ${{ steps.gitversion.outputs.fullSemVer }}
simple-version: ${{ steps.gitversion.outputs.semVer }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history needed for Nerdbank.GitVersioning
fetch-depth: 0 # Full history needed

- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x' # Adjust to your .NET version

- name: Install Nerdbank.GitVersioning
run: dotnet tool install -g nbgv
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v4.0.1
with:
versionSpec: '6.3.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v4.0.1

- name: Get Version from Nerdbank.GitVersioning
id: nbgv
- name: Display GitVersion outputs
run: |
nbgv cloud
echo "SemVer2=$(nbgv get-version -v SemVer2)" >> $GITHUB_OUTPUT
echo "SimpleVersion=$(nbgv get-version -v SimpleVersion)" >> $GITHUB_OUTPUT
echo "Version will be: $(nbgv get-version -v SemVer2)"
echo "SemVer: ${{ steps.gitversion.outputs.semVer }}"
echo "FullSemVer: ${{ steps.gitversion.outputs.fullSemVer }}"
echo "AssemblySemVer: ${{ steps.gitversion.outputs.assemblySemVer }}"
echo "InformationalVersion: ${{ steps.gitversion.outputs.informationalVersion }}"

- name: Restore dependencies
run: dotnet restore
Expand All @@ -41,12 +51,17 @@ jobs:
run: dotnet build --no-restore --configuration Release

- name: Run TUNIT tests
run: dotnet test ./tests --no-build --configuration Release
run: dotnet test --no-build --configuration Release

- name: Pack NuGet packages
run: |
dotnet pack ./src --no-build --configuration Release \
--output ./packages
dotnet pack --no-build --configuration Release \
--output ./packages \
-p:PackageVersion=${{ steps.gitversion.outputs.fullSemVer }} \
-p:Version=${{ steps.gitversion.outputs.assemblySemVer }} \
-p:AssemblyVersion=${{ steps.gitversion.outputs.assemblySemVer }} \
-p:FileVersion=${{ steps.gitversion.outputs.assemblySemVer }} \
-p:InformationalVersion=${{ steps.gitversion.outputs.informationalVersion }}

- name: Upload build artifacts
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -83,6 +98,9 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Download artifacts
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -114,20 +132,11 @@ jobs:
echo "## NuGet Package" >> release_notes.md
echo "This release is available on NuGet:" >> release_notes.md
echo '```' >> release_notes.md
echo "dotnet add package YourPackageName --version ${{ needs.build-and-test.outputs.version }}" >> release_notes.md
echo "dotnet add package TvdbClient --version ${{ needs.build-and-test.outputs.version }}" >> release_notes.md
echo '```' >> release_notes.md

- name: Create Git Tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ needs.build-and-test.outputs.simple-version }}" -m "Release v${{ needs.build-and-test.outputs.simple-version }}"
git push origin "v${{ needs.build-and-test.outputs.simple-version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ needs.build-and-test.outputs.simple-version }}
name: Release v${{ needs.build-and-test.outputs.simple-version }}
Expand All @@ -138,5 +147,7 @@ jobs:
./packages/*.tar.gz
draft: false
prerelease: ${{ contains(needs.build-and-test.outputs.version, '-') }}
generate_release_notes: true
make_latest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,6 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml

# TestResults
*.trx
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": []
}
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/TvdbClient.Tests/bin/Debug/net9.0/TvdbClient.Tests.dll",
"program": "${workspaceFolder}/tests/TvdbClient.Tests/bin/Debug/net9.0/TvdbClient.Tests.dll",
"args": [],
"cwd": "${workspaceFolder}/TvdbClient.Tests",
"cwd": "${workspaceFolder}/tests/TvdbClient.Tests",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
Expand Down
21 changes: 15 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup Label="Versioning">
<PackageReference Include="Nerdbank.GitVersioning" Condition="!Exists('packages.config')">
<PrivateAssets>all</PrivateAssets>
<Version>3.7.115</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup Label="Variables">
<CurrentYear>$([System.DateTime]::Now.ToString("yyyy"))</CurrentYear>
</PropertyGroup>

<PropertyGroup Label="GitVersion Integration">
<!-- Enable GitVersion integration for local builds -->
<EnableGitVersionTask Condition="'$(GITHUB_ACTIONS)' != 'true'">true</EnableGitVersionTask>
<!-- Use static fallback version when GitVersion is not available -->
<Version Condition="'$(GitVersion_FullSemVer)' == ''">4.7.10</Version>
<AssemblyVersion Condition="'$(GitVersion_AssemblySemVer)' == ''">4.7.10.0</AssemblyVersion>
<FileVersion Condition="'$(GitVersion_AssemblySemVer)' == ''">4.7.10.0</FileVersion>
<InformationalVersion Condition="'$(GitVersion_InformationalVersion)' == ''">4.7.10</InformationalVersion>
<!-- Use GitVersion values when available -->
<Version Condition="'$(GitVersion_FullSemVer)' != ''">$(GitVersion_FullSemVer)</Version>
<AssemblyVersion Condition="'$(GitVersion_AssemblySemVer)' != ''">$(GitVersion_AssemblySemVer)</AssemblyVersion>
<FileVersion Condition="'$(GitVersion_AssemblySemVer)' != ''">$(GitVersion_AssemblySemVer)</FileVersion>
<InformationalVersion Condition="'$(GitVersion_InformationalVersion)' != ''">$(GitVersion_InformationalVersion)</InformationalVersion>
</PropertyGroup>
</Project>
30 changes: 30 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
mode: ContinuousDelivery

branches:
main:
mode: ContinuousDelivery
increment: None
develop:
mode: ContinuousDeployment
label: 'alpha'
increment: None
release:
mode: ContinuousDelivery
label: 'beta'
increment: None
feature:
mode: ContinuousDeployment
label: 'feature'
increment: None
hotfix:
mode: ContinuousDeployment
label: 'hotfix'
increment: None

assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag

tag-prefix: 'v'

# Keep major.minor.patch static by not incrementing any version component
# The build metadata and prerelease tags will provide uniqueness
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,13 @@ Register TVDB Client with your DI of choice:
## Versioning

I try my best to align the version of this library to the latest TVDB version on their Github repository to make it easy to see which version this client is compatible with.

### Git Version

This project uses [GitVersion](https://gitversion.net/docs/usage) for automatic semantic versioning.

To view version information for a project, just run this command:

``` bash
dotnet-gitversion
```
1 change: 1 addition & 0 deletions src/TvdbClient/TvdbClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Scrutor.Extensions.HttpClient" Version="5.1.2-alpha.2" />
<PackageReference Include="GitVersion.MsBuild" Version="6.2.0" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Label="Package">
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand Down
18 changes: 0 additions & 18 deletions src/TvdbClient/version.json

This file was deleted.

7 changes: 6 additions & 1 deletion tests/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@
</PropertyGroup>
<ItemGroup Label="Nuget Packages">
<PackageReference Include="TUnit" Version="0.25.21" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="17.14.2" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="1.7.3" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="coverlet.collector" Version="6.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Moq" Version="4.20.72" />
</ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions tests/TvdbClient.Tests/TvdbClient.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.1" />

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />

<PackageReference Include="Scrutor.Extensions.HttpClient" Version="5.1.2-alpha.2" />
</ItemGroup>

Expand Down
Loading