From 236907b914b5a559f246b077937462f98e3f5106 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Sun, 20 Jul 2025 14:40:55 +1200 Subject: [PATCH 01/13] fix code coverage not working properly --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 59f4d1b..b5e523d 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -26,7 +26,7 @@ jobs: - name: Run TUNIT tests with coverage run: | - dotnet test ./tests --no-build --configuration Release \ + dotnet test --no-build --configuration Release \ --collect:"XPlat Code Coverage" \ --results-directory ./test-results \ --logger "trx;LogFileName=TestResults.trx" \ From 6d056967a04f6af8b303fc718bae36fe26c8c6ca Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 14:55:13 +1200 Subject: [PATCH 02/13] probably works now, lets see what github says but act is pretty happy apart from the upload task that fails --- .config/dotnet-tools.json | 12 ++++++++++ .github/workflows/release.yml | 38 ++++++++++++++++++++------------ .vscode/extensions.json | 3 +++ .vscode/launch.json | 4 ++-- Directory.Build.props | 21 +++++++++++++----- GitVersion.yml | 30 +++++++++++++++++++++++++ README.md | 10 +++++++++ src/TvdbClient/TvdbClient.csproj | 1 + src/TvdbClient/version.json | 18 --------------- 9 files changed, 97 insertions(+), 40 deletions(-) create mode 100644 .config/dotnet-tools.json create mode 100644 .vscode/extensions.json create mode 100644 GitVersion.yml delete mode 100644 src/TvdbClient/version.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..59f98fd --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "GitVersion.Tool": { + "version": "6.3.0", + "commands": [ + "dotnet-gitversion" + ] + } + } +} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7605d42..d99ca2a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,29 +10,34 @@ jobs: 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 @@ -41,12 +46,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 diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..7e257db --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": [] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 404e721..072a7d4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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 diff --git a/Directory.Build.props b/Directory.Build.props index fe6a208..df0880f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,13 +6,22 @@ enable enable - - - all - 3.7.115 - - $([System.DateTime]::Now.ToString("yyyy")) + + + + true + + 4.7.10 + 4.7.10.0 + 4.7.10.0 + 4.7.10 + + $(GitVersion_FullSemVer) + $(GitVersion_AssemblySemVer) + $(GitVersion_AssemblySemVer) + $(GitVersion_InformationalVersion) + \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..702aa44 --- /dev/null +++ b/GitVersion.yml @@ -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 diff --git a/README.md b/README.md index 78cfdeb..2e18e46 100644 --- a/README.md +++ b/README.md @@ -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 +``` diff --git a/src/TvdbClient/TvdbClient.csproj b/src/TvdbClient/TvdbClient.csproj index d99364d..270e6b7 100644 --- a/src/TvdbClient/TvdbClient.csproj +++ b/src/TvdbClient/TvdbClient.csproj @@ -9,6 +9,7 @@ + True diff --git a/src/TvdbClient/version.json b/src/TvdbClient/version.json deleted file mode 100644 index 7d9a7c7..0000000 --- a/src/TvdbClient/version.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json", - "version": "4.7.10", - "pathFilters": ["."], - "publicReleaseRefSpec": [ - "^refs/heads/main$", - "^refs/heads/release(/.*)?$" - ], - "cloudBuild": { - "buildNumber": { - "enabled": true, - "includeCommitId": { - "when": "nonPublicReleaseOnly", - "where": "buildMetadata" - } - } - } -} \ No newline at end of file From b8951ab1a5c41c9b595e940787b7fa59d3513ea8 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 15:31:54 +1200 Subject: [PATCH 03/13] update release workflow: enhance permissions, fix artifact download, and update package name --- .github/workflows/release.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d99ca2a..2d38397 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,11 @@ 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 @@ -93,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 @@ -124,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 }} @@ -148,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 }} \ No newline at end of file From 1564ea7341ba207390faf8c593beb97f203c3efe Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 15:34:53 +1200 Subject: [PATCH 04/13] code coverage for every branch --- .github/workflows/code-coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index b5e523d..c275a1d 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -2,9 +2,9 @@ name: Code Coverage on: push: - branches: [ main, develop ] + branches: [ "**" ] # Trigger on all branches pull_request: - branches: [ main ] + branches: [ "**" ] # Trigger on PRs to any branch jobs: test: From b2c507db3d54a8490b9d9a78ad6b621f07e27f96 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 15:47:46 +1200 Subject: [PATCH 05/13] full history for gitversion to work --- .github/workflows/code-coverage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index c275a1d..965e9d3 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -12,6 +12,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history needed - name: Setup .NET uses: actions/setup-dotnet@v4 From d4daeb365259f16b3b8e7e79945b60b760475d02 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 15:49:08 +1200 Subject: [PATCH 06/13] limit PR trigger --- .github/workflows/code-coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 965e9d3..83e401c 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -4,7 +4,7 @@ on: push: branches: [ "**" ] # Trigger on all branches pull_request: - branches: [ "**" ] # Trigger on PRs to any branch + branches: [ "main", "release/**" ] # Trigger on PRs to main and release branches jobs: test: From 5daa3b3ce52339e580ebf13f9f6b5e4a13f3a4ed Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 15:52:49 +1200 Subject: [PATCH 07/13] refactor: replace manual report generation with ReportGenerator GitHub Action --- .github/workflows/code-coverage.yml | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 83e401c..59663b5 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -34,16 +34,13 @@ jobs: --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" - + - name: Generate Code Coverage Report + uses: danielpalme/ReportGenerator-GitHub-Action@v5 + with: + reports: ./test-results/**/coverage.cobertura.xml + targetdir: ./coverage-report + reporttypes: Html;Cobertura;MarkdownSummaryGithub + - name: Upload test results uses: actions/upload-artifact@v4 if: always() From 3f9abe5615b2a5e7dfd88922ea91a859c0a4d407 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:09:20 +1200 Subject: [PATCH 08/13] fix coverage report --- .github/workflows/code-coverage.yml | 2 +- tests/Directory.Build.props | 7 ++++++- tests/TvdbClient.Tests/TvdbClient.Tests.csproj | 3 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 59663b5..081bc4b 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -29,7 +29,7 @@ jobs: - name: Run TUNIT tests with coverage run: | dotnet test --no-build --configuration Release \ - --collect:"XPlat Code Coverage" \ + -- --report-trx --coverage \ --results-directory ./test-results \ --logger "trx;LogFileName=TestResults.trx" \ --logger "console;verbosity=detailed" diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index d5634e1..87e9600 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -7,8 +7,13 @@ + + - + + all + runtime; build; native; contentfiles; analyzers + diff --git a/tests/TvdbClient.Tests/TvdbClient.Tests.csproj b/tests/TvdbClient.Tests/TvdbClient.Tests.csproj index 63e415c..6444a4c 100644 --- a/tests/TvdbClient.Tests/TvdbClient.Tests.csproj +++ b/tests/TvdbClient.Tests/TvdbClient.Tests.csproj @@ -20,9 +20,6 @@ - - - From 5c5b5b482e68c17c919f4cf923ad5abd61ab6174 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:10:35 +1200 Subject: [PATCH 09/13] remove logger from tunit --- .github/workflows/code-coverage.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 081bc4b..5021ba7 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -30,9 +30,7 @@ jobs: run: | dotnet test --no-build --configuration Release \ -- --report-trx --coverage \ - --results-directory ./test-results \ - --logger "trx;LogFileName=TestResults.trx" \ - --logger "console;verbosity=detailed" + --results-directory ./test-results - name: Generate Code Coverage Report uses: danielpalme/ReportGenerator-GitHub-Action@v5 From 8d222c5d7f60f3090e780d34ef0b501e972e6e6d Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:17:48 +1200 Subject: [PATCH 10/13] ignore test results on git --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 28b232f..a62bf16 100644 --- a/.gitignore +++ b/.gitignore @@ -398,3 +398,6 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml + +# TestResults +*.trx \ No newline at end of file From ee1464e088e06c267f53fce6c9ff4adaadb50d17 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:18:14 +1200 Subject: [PATCH 11/13] continue on error in TUNIT (can happen when not enough tests pass) --- .github/workflows/code-coverage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 5021ba7..8d78411 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -31,6 +31,7 @@ jobs: 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 From 1c232a21bedd46113a25ea57a0133a2df848f977 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:37:35 +1200 Subject: [PATCH 12/13] fix file paths --- .github/workflows/code-coverage.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 8d78411..5860b26 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -36,7 +36,7 @@ jobs: - name: Generate Code Coverage Report uses: danielpalme/ReportGenerator-GitHub-Action@v5 with: - reports: ./test-results/**/coverage.cobertura.xml + reports: '**/*.coverage' targetdir: ./coverage-report reporttypes: Html;Cobertura;MarkdownSummaryGithub @@ -46,15 +46,15 @@ jobs: 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 From abcdb89c8bde435a162639dbbdb983a7bda1cf82 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 21 Jul 2025 16:43:51 +1200 Subject: [PATCH 13/13] add missing permissions --- .github/workflows/code-coverage.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 5860b26..6be78c7 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -6,6 +6,11 @@ on: pull_request: branches: [ "main", "release/**" ] # Trigger on PRs to main and release branches +permissions: + contents: read + actions: read + checks: write + jobs: test: runs-on: ubuntu-latest