-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
|
||
jobs: | ||
build: | ||
name: Test dotnet ${{ matrix.dotnet-version }} on ${{ matrix.operating-system }} | ||
|
||
runs-on: ${{ matrix.operating-system }} | ||
|
||
strategy: | ||
matrix: | ||
operating-system: ['ubuntu-latest', 'windows-latest'] | ||
dotnet-version: ['9.0.x'] | ||
include: | ||
- operating-system: 'windows-latest' | ||
dotnet-version: '9.0.x' | ||
run-sonarqube-analysis: true | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 17 for SonarQube | ||
if: matrix.run-sonarqube-analysis | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: 17 | ||
distribution: 'zulu' | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
|
||
- name: Install dotnet-coverage | ||
if: matrix.run-sonarqube-analysis | ||
shell: bash | ||
run: dotnet tool install --global dotnet-coverage | ||
|
||
- name: Cache SonarCloud packages | ||
uses: actions/cache@v4 | ||
if: matrix.run-sonarqube-analysis | ||
with: | ||
path: ~\sonar\cache | ||
key: ${{ runner.os }}-sonar | ||
restore-keys: ${{ runner.os }}-sonar | ||
|
||
- name: Cache SonarCloud scanner | ||
id: cache-sonar-scanner | ||
if: matrix.run-sonarqube-analysis | ||
uses: actions/cache@v4 | ||
with: | ||
path: .\.sonar\scanner | ||
key: ${{ runner.os }}-sonar-scanner | ||
restore-keys: ${{ runner.os }}-sonar-scanner | ||
|
||
- name: Install SonarCloud scanner | ||
if: matrix.run-sonarqube-analysis && 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: Build and analyze | ||
if: matrix.run-sonarqube-analysis | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
shell: powershell | ||
run: | | ||
.\.sonar\scanner\dotnet-sonarscanner begin ` | ||
/k:"Namoshek_Shouldly.Json" ` | ||
/o:"namoshek" ` | ||
/d:sonar.host.url="https://sonarcloud.io" ` | ||
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" ` | ||
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | ||
dotnet build --configuration "Release" --no-incremental | ||
dotnet-coverage collect 'dotnet test --no-restore --no-build --configuration Release' -f xml -o 'coverage.xml' | ||
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | ||
- name: Build package | ||
if: matrix.run-sonarqube-analysis != true | ||
run: dotnet build --configuration 'Release' | ||
|
||
- name: Run tests | ||
if: matrix.run-sonarqube-analysis != true | ||
run: dotnet test --configuration 'Debug' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Publish NuGet package | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '9.0.x' | ||
|
||
- name: Build packages | ||
run: dotnet build --configuration 'Release' | ||
|
||
- name: Pack NuGet packages | ||
run: dotnet pack --configuration 'Release' --output 'out' | ||
|
||
- name: Push NuGet packages to nuget.org | ||
run: dotnet nuget push **/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate |