-
Notifications
You must be signed in to change notification settings - Fork 4
98 lines (94 loc) · 3.92 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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