diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 6f1cfc9..aa78761 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,21 +15,19 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x + uses: actions/setup-dotnet@v5 - name: Restore dependencies run: dotnet restore $solution - name: Build run: dotnet build $solution --no-restore - name: Test - run: dotnet test $solution --no-build --verbosity normal + run: dotnet test $solution --verbosity normal - name: Pack - run: dotnet pack $solution --no-build --include-source --output pkgs + run: dotnet pack $solution --output pkgs - name: Upload Package as a Build Artifact - uses: actions/upload-artifact@v3.1.0 + uses: actions/upload-artifact@v7 with: name: package path: pkgs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ebf670b..a7c3893 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,19 +11,19 @@ jobs: create_nuget: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4.1.1 + - uses: actions/checkout@v6 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 + uses: actions/setup-dotnet@v5 # Create the NuGet package in the folder from the environment variable NuGetDirectory - run: dotnet pack $PROJECT --configuration Release --output ${{ env.NuGetDirectory }} # Publish the NuGet package as an artifact, so they can be used in the following jobs - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@v7 with: name: nuget if-no-files-found: error @@ -36,10 +36,10 @@ jobs: steps: # Install the .NET SDK indicated in the global.json file - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 # Download the NuGet package created in the previous job - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v7 with: name: nuget path: ${{ env.NuGetDirectory }} @@ -52,14 +52,14 @@ jobs: # 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: meziantou.validate-nuget-package $(ls ${{ env.NuGetDirectory }}/*.nupkg) run_test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Setup .NET - uses: actions/setup-dotnet@v4 + uses: actions/setup-dotnet@v5 - name: Run tests run: dotnet test $PROJECT --configuration Release @@ -72,20 +72,20 @@ jobs: needs: [ validate_nuget, run_test ] steps: # Download the NuGet package created in the previous job - - uses: actions/download-artifact@v4 + - uses: actions/download-artifact@v7 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 + uses: actions/setup-dotnet@v5 # 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_TOKEN }}" --source https://api.nuget.org/v3/index.json --skip-duplicate - } + for file in "${{ env.NuGetDirectory }}"/*.nupkg; do + dotnet nuget push "$file" --api-key "${{ secrets.NUGET_TOKEN }}" --source https://api.nuget.org/v3/index.json --skip-duplicate + done diff --git a/.github/workflows/sonar.yml b/.github/workflows/sonar.yml deleted file mode 100644 index 3f8df9a..0000000 --- a/.github/workflows/sonar.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: SonarCloud -on: - push: - branches: - - main - pull_request: - types: [opened, synchronize, reopened] -env: - projectfile: src/DecimalChecker.sln -jobs: - build: - name: Build and analyze - runs-on: windows-latest - steps: - - name: Set up JDK 21 - uses: actions/setup-java@v4.1.0 - with: - java-version: 21 - distribution: 'zulu' # Alternative distribution options are available. - - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - - name: Cache SonarCloud packages - uses: actions/cache@v4.0.1 - with: - path: ~\sonar\cache - key: ${{ runner.os }}-sonar - restore-keys: ${{ runner.os }}-sonar - - name: Cache SonarCloud scanner - id: cache-sonar-scanner - uses: actions/cache@v4.0.1 - with: - path: .\.sonar\scanner - key: ${{ runner.os }}-sonar-scanner - restore-keys: ${{ runner.os }}-sonar-scanner - - name: Install SonarCloud scanner - if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' - shell: powershell - run: | - New-Item -Path .\.sonar\scanner -ItemType Directory - dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner - - name: Install dotnet-coverage - shell: powershell - run: | - dotnet tool install --global dotnet-coverage - - name: Build and analyze - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - shell: powershell - run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"grimley517_DecimalToSqlChecker" /o:"grimley517" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" - dotnet build ${{ env.projectfile }} - dotnet-coverage collect "dotnet test ${{ env.projectfile }}" -f xml -o "coverage.xml" - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" diff --git a/global.json b/global.json new file mode 100644 index 0000000..cdbb589 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "9.0.100", + "rollForward": "latestFeature" + } +} diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..53de392 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,4 @@ +sonar.projectKey=grimley517_DecimalToSqlChecker +sonar.organization=grimley517 +sonar.host.url=https://sonarcloud.io +sonar.cs.opencover.reportsPaths=coverage.xml diff --git a/src/DecimalChecker.Tests/DecimalChecker.Tests.csproj b/src/DecimalChecker.Tests/DecimalChecker.Tests.csproj index 3ea8e59..c9b3671 100644 --- a/src/DecimalChecker.Tests/DecimalChecker.Tests.csproj +++ b/src/DecimalChecker.Tests/DecimalChecker.Tests.csproj @@ -1,7 +1,6 @@ - net6.0 enable false diff --git a/src/DecimalChecker/DecimalChecker.csproj b/src/DecimalChecker/DecimalChecker.csproj index 5cfec49..566a2df 100644 --- a/src/DecimalChecker/DecimalChecker.csproj +++ b/src/DecimalChecker/DecimalChecker.csproj @@ -1,7 +1,6 @@ - net6.0 enable enable true diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..67b2324 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,5 @@ + + + net9.0 + +