-
Notifications
You must be signed in to change notification settings - Fork 9
272 lines (230 loc) · 8.93 KB
/
compile.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: Build & Test
on:
push:
pull_request:
jobs:
build:
runs-on: windows-latest
defaults:
run:
working-directory: .
outputs:
semver: ${{ steps.gitversion.outputs.semver }}
LicenseClearingTool: ${{ steps.packageBuildResults.outputs.LicenseClearingTool }}
nupkg-LicenseClearingTool: ${{ steps.createNupkg.outputs.nupkg-LicenseClearingTool }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Version
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.12.0'
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: TRUE
- name: Determine Version
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: TRUE
- name: get SemVer
#if: ${{ false }} # disable for now
id: gitversion
run: |
echo "SemVer: v$($env:GitVersion_SemVer)"
Write-Host "::set-output name=semver::$($env:GitVersion_MajorMinorPatch)"
$fileName = "dummy-v$($env:GitVersion_SemVer)"
echo "SemVerMMP: v$($env:GitVersion_MajorMinorPatch)"
Write-Host "Filename: '$fileName'"
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: update appsettingsUnitTest.json
run: ./Scripts/json_update_ut.ps1 -JsonFile 'src\UnitTestUtilities\appsettingsUnitTest.json'
env:
SW360HOST: ${{ secrets.SW360HOST }}
SW360APPPORT: ${{ secrets.SW360APPPORT }}
FOSSYHOST: ${{ secrets.FOSSYHOST }}
FOSSYAPPPORT: ${{ secrets.FOSSYAPPPORT }}
JFROGURL: ${{ secrets.JFROGURL }}
- name: Restore Packages
run: dotnet restore src\LicenseClearingTool.sln
- name: Build
run: |
dotnet build src\LicenseClearingTool.sln
Write-Host "Files in directory:"
dir $env:GITHUB_WORKSPACE\out\net8.0
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: buildoutput
path: ${{ github.workspace }}/out/net8.0
- name: Archive Build Log
uses: actions/upload-artifact@v4
if: ${{ success() || failure() }}
with:
name: Compile_Solution_log
path: |
$env:GITHUB_WORKSPACE/src/*.binlog
$env:GITHUB_WORKSPACE/*.binlog
- name: Archive Build Output
uses: actions/upload-artifact@v4
with:
name: continuous-clearing
path: |
out/continuous-clearing
- name: Create zip
id: packageBuildResults
run: |
$sourceFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "*"
$outFolder = Join-Path $env:GITHUB_WORKSPACE "out" | Join-Path -ChildPath "continuous-clearing"
New-Item -ItemType Directory -Force -Path $outFolder
$fileName = "continuous-clearing-v7.0.0.zip"
Write-Host "Filename: '$fileName'"
Write-Host "sourceFolder: '$sourceFolder'"
Write-Host "Outfolder: '$outFolder'"
Write-Host "::set-output name=LicenseClearingTool::$($fileName)"
$outPath = Join-Path $outFolder $fileName
Compress-Archive -DestinationPath $outPath -Path $sourceFolder -CompressionLevel Optimal
- name: Test
#if: ${{ false }} # disable for now
run: |
$TestProjects = Get-ChildItem -Path *test*.csproj -Recurse -exclude TestUtilities.csproj,UnitTestUtilities.csproj,SW360IntegrationTest.csproj
Write-Host "**************************The test projects considered for execution: $TestProjects ******************************"
Write-Host "********************************************************************************************************************"
foreach ($Project in $TestProjects)
{
Write-Host $Project.DirectoryName
$TestProject = $Project.DirectoryName
Push-Location $Project.PSParentPath
dotnet test --no-build --configuration Release
}
- name: Archive Build Output
uses: actions/upload-artifact@v4
with:
name: continuous-clearing
path: |
out/continuous-clearing
- name: Create Nuget Packages
id: createNupkg
run: |
nuget pack CA.nuspec -Version 7.0.0
Write-Host "::set-output name=nupkg-LicenseClearingTool::continuous-clearing.7.0.0.nupkg"
- name: Archive NuGet Packages
uses: actions/upload-artifact@v4
with:
name: nuget-continuous-clearing
path: |
*.nupkg
build-docker:
runs-on: ubuntu-latest
needs: build
outputs:
docker-LicenseClearingTool: ${{ steps.builddocker.outputs.docker-LicenseClearingTool }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download Build Output
uses: actions/download-artifact@v4
with:
name: buildoutput
path: ${{ github.workspace }}/buildoutput
- name: Build the Docker image
id: builddocker
#if: ${{ false }} # disable for now
run: |
echo "Files in directory:"
docker build . --file Dockerfile --tag ${{ github.repository }}:continuous-clearing-v7.0.0
docker save ${{ github.repository }}:continuous-clearing-v7.0.0 -o continuous-clearing-v7.0.0.tar
echo "::set-output name=docker-LicenseClearingTool::continuous-clearing-v7.0.0.tar"
- name: Archive docker image
#if: ${{ false }} # disable for now
uses: actions/upload-artifact@v4
with:
name: docker-continuous-clearing
path: |
*.tar
release:
if: github.ref == 'refs/heads/main'
runs-on: windows-latest
needs: [build, build-docker]
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download Build Output
uses: actions/download-artifact@v4
with:
name: continuous-clearing
- name: Download NuGet Package
uses: actions/download-artifact@v4
with:
name: nuget-continuous-clearing
- name: Download Docker image
uses: actions/download-artifact@v4
with:
name: docker-continuous-clearing
- name: Debug
run: |
tree
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v7.0.0
release_name: Release v7.0.0
body: |
${{ github.event.head_commit.message }}
draft: true
prerelease: false
- name: Upload Zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ needs.build.outputs.LicenseClearingTool }}
asset_name: ${{ needs.build.outputs.LicenseClearingTool }}
asset_content_type: application/zip
- name: Upload Nupkg
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ needs.build.outputs.nupkg-LicenseClearingTool }}
asset_name: ${{ needs.build.outputs.nupkg-LicenseClearingTool }}
asset_content_type: application/zip
- name: Upload Docker
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ needs.build-docker.outputs.docker-LicenseClearingTool }}
asset_name: ${{ needs.build-docker.outputs.docker-LicenseClearingTool }}
asset_content_type: application/zip
- name: Upload ReadmeOSS_nupkg file
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 }}\ReadmeOSS_continuous-clearing_nupkg.html
asset_name: ReadmeOSS_continuous-clearing_nupkg.html
asset_content_type: text/html
- name: Upload ReadmeOSS_Docker file
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 }}\ReadmeOSS_continuous-clearing_DockerImage.html
asset_name: ReadmeOSS_continuous-clearing_DockerImage.html
asset_content_type: text/html