Merge pull request #196 from odalet/dependabot/nuget/SonarAnalyzer.CS… #377
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: Build | |
on: | |
push: | |
tags: ["v*"] | |
branches: [master] | |
pull_request: | |
branches: [master] | |
env: | |
SOLUTION: src/Delta.CertXplorer.sln | |
DOTNET_ROLL_FORWARD: LatestMajor | |
BUILD_CONFIGURATION: Release | |
defaults: | |
run: | |
shell: cmd | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Dump Environment | |
run: | | |
echo "Solution : ${{ env.SOLUTION }}" | |
echo "Configuration : ${{ env.BUILD_CONFIGURATION }}" | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # See https://github.com/GitTools/GitVersion/issues/2301 | |
# Java 17 is needed by Sonar analyzer | |
- name: Setup Java 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
java-package: jdk | |
architecture: x64 | |
- name: Setup .NET 6 | |
uses: actions/setup-dotnet@v1 | |
with: | |
dotnet-version: "8.0.x" | |
- name: Setup MSBuild.exe | |
uses: microsoft/setup-msbuild@v1 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/[email protected] | |
with: | |
versionSpec: "5.x" | |
- name: Use GitVersion | |
id: gitversion # step id used as reference for output values | |
uses: gittools/actions/gitversion/[email protected] | |
- name: Install SonarScanner | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: dotnet tool install --global dotnet-sonarscanner | |
- name: Restore | |
run: dotnet restore "${{ env.SOLUTION }}" --configfile ./nuget.config | |
- name: Begin Sonar Analysis | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: dotnet sonarscanner begin /key:"odalet_CertXplorer" /name:"CertXplorer" /version:"${{ steps.gitversion.outputs.majorMinorPatch }}" /organization:"odalet" /d:sonar.cs.vstest.reportsPaths="**/TestResults/**/*.trx" /d:sonar.cs.opencover.reportsPaths="**/TestResults/**/*.opencover.xml" /d:sonar.coverage.exclusions="**Tests.cs" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.verbose=true /d:sonar.host.url=https://sonarcloud.io | |
- name: Build | |
run: dotnet build "${{ env.SOLUTION }}" --configuration "${{ env.BUILD_CONFIGURATION }}" --no-restore | |
- name: Test | |
run: dotnet test "${{ env.SOLUTION }}" --configuration "${{ env.BUILD_CONFIGURATION }}" --no-restore --no-build --logger trx --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:CoverletOutput=./TestResults/ | |
- name: End Sonar Analysis | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: dotnet sonarscanner end /d:sonar.login="${{secrets.SONAR_TOKEN}}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Collect Windows executable | |
uses: actions/upload-artifact@v2 | |
with: | |
name: CertXplorer | |
path: ${{ github.workspace }}/src/Delta.CertXplorer/bin/Release/net48/* | |
########################################### | |
# Release creation / publication | |
- name: Create Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ github.ref }} | |
draft: true | |
prerelease: false | |
- name: Zip Windows executable | |
if: startsWith(github.ref, 'refs/tags/v') | |
run: 7z a ${{ github.workspace }}/CertXplorer.zip ${{ github.workspace }}/src/Delta.CertXplorer/bin/Release/net48/*.* | |
- name: Upload Windows executable to Release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ github.workspace }}/CertXplorer.zip | |
asset_name: CertXplorer.zip | |
asset_content_type: application/zip |