-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (98 loc) · 3.88 KB
/
build.yml
File metadata and controls
120 lines (98 loc) · 3.88 KB
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
name: Build and Test
on:
push:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
packages: read
actions: read
jobs:
build:
runs-on: windows-latest
timeout-minutes: 10
outputs:
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '9.0.x'
- name: Set version
id: get_version
shell: pwsh
run: |
$TAG = if ($env:GITHUB_REF -like "refs/tags/v*") {
$env:GITHUB_REF -replace 'refs/tags/v', ''
} else {
""
}
if ($TAG -ne "") {
$VERSION = $TAG
} else {
# Fallback to commit hash if no tag
$COMMIT_HASH = git rev-parse --short HEAD
$VERSION = "0.0.1-$COMMIT_HASH"
}
echo "VERSION=$VERSION" >> $env:GITHUB_OUTPUT
- name: Generate SBOM for the project
uses: advanced-security/generate-sbom-action@67c5cda0176c46ce546d2fee672f72cee7fd620f # v1
id: gensbom
- name: Build AggregateConfigBuildTask solution in Release mode
run: dotnet build src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Run tests for AggregateConfigBuildTask solution
run: dotnet test src/dirs.proj --configuration Release -warnaserror -p:Version=${{ steps.get_version.outputs.VERSION }} -p:CollectCoverage=true --no-build
- name: Upload SBOM artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: sbom
path: ${{ steps.gensbom.outputs.fileName }}
- name: Upload NuGetPackage artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: NuGetPackage
path: |
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.nupkg
src/Task/bin/Release/AggregateConfigBuildTask.${{ steps.get_version.outputs.VERSION }}.snupkg
integration_tests:
needs: build
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 1
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5
with:
dotnet-version: '9.0.x'
- name: Download NuGetPackage artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: NuGetPackage
path: ./nuget/local
- name: Add local NuGet source
run: dotnet nuget add source ${{ github.workspace }}/nuget/local --name AggregateConfigBuildTask
- name: Build IntegrationTests in Release mode
run: dotnet build test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:UseLocalPackageVersion=true
- name: Run IntegrationTests
run: dotnet test test/dirs.proj --configuration Release -warnaserror -p:Version=${{ needs.build.outputs.VERSION }} -p:CollectCoverage=true -p:UseLocalPackageVersion=true
- name: Upload integration results artifact
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: IntegrationTestResults-${{ matrix.os }}
path: test/IntegrationTests/out/