-
Notifications
You must be signed in to change notification settings - Fork 5
148 lines (124 loc) · 5.14 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Verification Build
on:
push:
branches:
- develop
pull_request:
types: [opened, synchronize, reopened]
env:
solution: 'MinoriEditorShell.sln'
buildPlatform: Any CPU
buildConfiguration: Release
jobs:
build:
name: Build
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
# if trying to build locally, make sure you have dotnet 3.1, 5.0 installed
# this container should have them pre-installed
# Needed for sonar analysis, even though java is installed
# sonar will not pick up version 11, so state specifically
# adopt is in tool cache so install should be quidker with it.
- name: Set up JDK 18
uses: actions/setup-java@v2
with:
distribution: 'adopt-hotspot' # Cached java
java-version: '18'
# Install GitVersion
# Requires .NET Core 3.1
# https://github.com/marketplace/actions/gittools
- name: 'Install GitVersion'
uses: gittools/actions/gitversion/setup@v0
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0
with:
useConfigFile: true
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1
- name: Use NuGet > 5.0.0
uses: nuget/setup-nuget@v1
- name: Restore dependencies
run: dotnet restore ${{env.solution}}
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{runner.os}}-sonar
restore-keys: ${{runner.os}}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v1
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: Prepare Scanner
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:"mkromis_MinoriEditorShell" /o:"mkromis"
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io"
/d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml
/v:${{steps.gitversion.outputs.semVer}}
# projects uses GitVersion.MsBuild, so don't neeed to pass version
- name: Build
run: >
dotnet build ${{env.solution}}
--configuration ${{env.buildConfiguration}} --no-restore
-p:Version=${{steps.gitversion.outputs.FullSemVer}}
-p:FileVersion=${{steps.gitversion.outputs.AssemblySemFileVer}}
-p:InformationalVersion=${{steps.gitversion.outputs.InformationalVersion}}
- name: Create Artifacts
run: |
# Get list of all nupkgs
$nupkgs = Get-ChildItem -Path .\Modules -Filter *.nupkg -Recurse
$basedir = 'MinoriEditorSystem-' + $env:GitVersion_NuGetVersion
# Move each item into artifacts
# rm Artifacts -Recurse -Force
mkdir Artifacts\$basedir\Nugets
# Copy nugets to nuget folder
foreach ($nupkg in $nupkgs) {
$leaf = Split-Path $nupkg -Leaf
$outFile = "Artifacts\$basedir\Nugets\$leaf"
echo $nupkg.FullName ' -> ' $outFile
Copy-Item $nupkg.FullName $outFile
}
# Copy Demo Folder
#mkdir Artifacts\$basedir\Demos
cp Demos\SimpleDemo\SimpleDemo.WPF\bin\Release\net6.0-windows Artifacts\$basedir\Demos\SimpleDemo.WPF -Recurse
cp Demos\SimpleDemo\SimpleDemo.RibbonWPF\bin\Release\net6.0-windows Artifacts\$basedir\Demos\SimpleDemo.RibbonWPF -Recurse
cp Demos\MinoriDemo\MinoriDemo.WPF\bin\Release\net6.0-windows Artifacts\$basedir\Demos\MinoriDemo.WPF -Recurse
cp Demos\MinoriDemo\MinoriDemo.RibbonWPF\bin\Release\net6.0-windows Artifacts\$basedir\Demos\MinoriDemo.RibbonWPF -Recurse
# Compress folder into 7z file
cd Artifacts
7z a "$basedir.7z" $basedir
cd ..
- name: Test
run: dotnet test ${{env.solution}} --collect:"XPlat Code Coverage" --settings coverlet.runsettings
- name: Analyze build
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 end /d:sonar.login="${{secrets.SONAR_TOKEN}}"
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: MinoriEditorShell
path: Artifacts/*.7z
if-no-files-found: error