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/code-coverage.yml b/.github/workflows/code-coverage.yml index 59f4d1b..6be78c7 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -2,9 +2,14 @@ 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: @@ -12,6 +17,8 @@ jobs: steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Full history needed - name: Setup .NET uses: actions/setup-dotnet@v4 @@ -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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7605d42..2d38397 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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 @@ -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 @@ -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 }} @@ -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 }} \ No newline at end of file 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 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 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 @@ - - -