-
Notifications
You must be signed in to change notification settings - Fork 4
182 lines (148 loc) · 7.01 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Build
on:
push:
tags: v[1-9]+.[0-9]+.[0-9]+
branches: [ master ]
pull_request:
jobs:
build:
runs-on: windows-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/checkout@v4
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Cache nuget packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
nuget-
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1.1.1
with:
versionSpec: '5.x'
- name: Check GitVersion
id: gitversion # step id used as reference for output values
uses: gittools/actions/gitversion/execute@v1.1.1
- name: Echo version
run: echo ${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name: Build
id: build
run: |
dotnet build src --configuration Release
echo "release_folder=./src/NVika/bin/Release/net8.0" >> $env:GITHUB_OUTPUT
- name: Test
run: dotnet test src --configuration Release --no-build --nologo --verbosity normal /p:CollectCoverage=true /p:CoverletOutputFormat=opencover
- name: InspectCode Analysis - old xml
run: |
nuget install JetBrains.ReSharper.CommandLineTools -ExcludeVersion -OutputDirectory tools
./tools/JetBrains.ReSharper.CommandLineTools/tools/inspectcode -o="inspectcodereport.xml" --project="NVika" "src\Vika.sln" -f=xml
- uses: actions/upload-artifact@v4
with:
path: inspectcodereport.xml
name: inspectcodereport.xml
- name: InspectCode Analysis
run: |
nuget install JetBrains.ReSharper.CommandLineTools -ExcludeVersion -OutputDirectory tools
./tools/JetBrains.ReSharper.CommandLineTools/tools/inspectcode -o="inspectcodereport.json" --project="NVika" "src\Vika.sln"
- uses: actions/upload-artifact@v4
with:
path: inspectcodereport.json
name: inspectcodereport.json
- name: LaunchNVika
run: ${{ steps.build.outputs.release_folder }}/NVika.exe --debug --includesource inspectcodereport.xml inspectcodereport.json ${{ steps.build.outputs.release_folder }}/static-analysis.sarif.json
- name: Create Nuget package
run: dotnet pack src --configuration Release --nologo --no-build /p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
- name: Create MSBuild package
run: |
Copy-Item -Path resources/icon.png -Destination src\NVika.MSBuild\
mkdir src\NVika.MSBuild\tools\
Copy-Item -Path "${{ steps.build.outputs.release_folder }}/publish/*" -Destination src\NVika.MSBuild\tools\
nuget pack src/NVika.MSBuild/NVika.MSBuild.nuspec -Version ${{ steps.gitversion.outputs.nuGetVersionV2 }} -OutputDirectory artifacts/nuget
- name: Create netcore packages
run: |
mkdir ./artifacts/zips
Compress-Archive -Path ${{ steps.build.outputs.release_folder }}/publish/* -DestinationPath "artifacts/zips/NVika.netcore.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip"
Copy-Item -Path "src/NVika/bin/Release/NVika.${{ steps.gitversion.outputs.nuGetVersionV2 }}.nupkg" -Destination artifacts/nuget
- name: Create windows version
run: |
dotnet publish src/NVika --configuration Release --output ./publish --runtime win-x64 -p:PublishAot=true -p:PublishTrimmed=true /p:PackAsTool=false /p:Version=${{ steps.gitversion.outputs.nuGetVersionV2 }}
Compress-Archive -Path publish/* -DestinationPath "artifacts/zips/NVika.win-x64.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip"
- name: Create chocolatey version
run: |
$winVersionChecksum = (Get-FileHash "artifacts/zips/NVika.win-x64.${{ steps.gitversion.outputs.nuGetVersionV2 }}.zip" -Algorithm SHA256).Hash
mkdir ./artifacts/chocolatey
$installPath = "chocolatey/tools/chocolateyInstall.ps1"
$originalContent = Get-Content $installPath
$originalContent.replace('[version]', "${{ steps.gitversion.outputs.nuGetVersionV2 }}").replace('[checksum]', $winVersionChecksum) | Set-Content $installPath
choco pack chocolatey/nvika.nuspec --version ${{ steps.gitversion.outputs.nuGetVersionV2 }} --outdir artifacts/chocolatey
Set-Content $installPath $originalContent
- uses: actions/upload-artifact@v4
with:
path: artifacts/*
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [build]
runs-on: windows-latest
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
steps:
- uses: actions/download-artifact@v4
name: artifact
- name: Display structure of downloaded files
run: ls -R
- name: Get the version
id: get_version
run: |
$version = $env:GITHUB_REF.Replace('refs/tags/v', '')
echo "::set-output name=VERSION::$version"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ${{ env.SemanticReleaseNotes }}
draft: false
prerelease: false
- name: Upload Zip netcore
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/zips/NVika.netcore.${{ steps.get_version.outputs.version }}.zip
asset_name: NVika.netcore.${{ steps.get_version.outputs.version }}.zip
asset_content_type: application/zip
- name: Upload Zip win-x64
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./artifact/zips/NVika.win-x64.${{ steps.get_version.outputs.version }}.zip
asset_name: NVika.win-x64.${{ steps.get_version.outputs.version }}.zip
asset_content_type: application/zip
- name: Chocolatey push
run: choco push artifact/chocolatey/nvika.${{ steps.get_version.outputs.version }}.nupkg --source=https://push.chocolatey.org/ --api-key=$env:CHOCO_API_KEY
env:
CHOCO_API_KEY: ${{ secrets.CHOCO_API_KEY }}
- name: Nuget push Tool
run: dotnet nuget push artifact/nuget/NVika.${{ steps.get_version.outputs.version }}.nupkg -s https://api.nuget.org/v3/index.json -k $env:NUGET_API_KEY
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
- name: Nuget push MSBuild
run: dotnet nuget push artifact/nuget/NVika.MSBuild.${{ steps.get_version.outputs.version }}.nupkg -s https://api.nuget.org/v3/index.json -k $env:NUGET_API_KEY
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}