Merge pull request #58 from lk-code/FDB-24 #70
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
name: .NET Build | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
VERSION: 1.1.${{ github.run_number }} | |
steps: | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3.13.0 | |
with: | |
java-version: 17 | |
distribution: 'zulu' | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: 7.0.x | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Pages | |
uses: actions/configure-pages@v3 | |
- name: Restore dependencies | |
run: dotnet restore source/ | |
- name: Version Visual Studio SDK projects | |
uses: roryprimrose/set-vs-sdk-project-version@v1.0.6 | |
with: | |
# The wildcard filter that identifies projects to version | |
projectFilter: "**/*.csproj" | |
# Maps to the Version element | |
version: ${{ env.VERSION }} | |
# Maps to the AssemblyVersion element | |
assemblyVersion: ${{ env.VERSION }} | |
# Maps to the FileVersion element | |
fileVersion: ${{ env.VERSION }} | |
# Maps to the InformationalVersion element | |
informationalVersion: ${{ env.VERSION }} | |
- name: Cache SonarCloud packages | |
uses: actions/cache@v3.3.2 | |
with: | |
path: ~\sonar\cache | |
key: ${{ runner.os }}-sonar | |
restore-keys: ${{ runner.os }}-sonar | |
- name: Cache SonarCloud scanner | |
id: cache-sonar-scanner | |
uses: actions/cache@v3.3.2 | |
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: pwsh | |
run: | | |
dotnet tool update -g dotnet-sonarscanner | |
dotnet tool update -g dotnet-reportgenerator-globaltool | |
dotnet tool update -g 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: pwsh | |
run: | | |
dotnet-sonarscanner begin /k:"lk-code_fluent-data-builder" /o:"lk-code-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml | |
dotnet build --configuration Release --no-restore -p:PackageVersion=${{ env.VERSION }} source/ | |
dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml" | |
reportgenerator "-reports:coverage.xml" "-targetdir:sonarqubecoverage" "-reporttypes:SonarQube" | |
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" | |
- name: Set Version Git Tag | |
run: | | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3.1.2 | |
with: | |
name: ${{ env.VERSION }} | |
path: "**/*.nupkg" |