-
Notifications
You must be signed in to change notification settings - Fork 3
120 lines (99 loc) · 3.62 KB
/
CI.yaml
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: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
env:
CONFIGURATION: Release
# Directories
OUTPUT_DIR: output
TEMP_DIR: temp
TEST_RESULTS_DIR: ./output/test-results
REPORTS_DIR: ./output/reports
COVERAGE_REPORT_DIR: ./output/reports/coverage-report
COVERAGE_HISTORY_DIR: ./temp/coverage-history
REPOSITORY_NAME: ${{ github.event.repository.name }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- 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: Restore dependencies
run: dotnet restore
- name: Build
run: |
dotnet build --no-restore \
/property:ContinuousIntegrationBuild=True \
/property:DeterministicSourcePaths=True \
/property:RepositoryUrl=https://github.com/${{ github.repository }} \
/property:AssemblyVersion=${{ env.GitVersion_AssemblySemVer }} \
/property:FileVersion=${{ env.GitVersion_AssemblySemFileVer }} \
/property:InformationalVersion=${{ env.GitVersion_InformationalVersion }}
- name: Setup test dependencies
run: docker compose up -d --wait
- name: Test
run: |
dotnet test --no-restore --no-build \
--logger "trx;LogFileName=${{ env.REPOSITORY_NAME }}.trx" \
--results-directory ${{ env.TEST_RESULTS_DIR }} \
--collect:"XPlat Code Coverage" \
/property:CollectCoverage=True \
/property:CoverletOutputFormat=opencover \
/property:CoverletOutput=${{ env.TEST_RESULTS_DIR }}/${{ env.REPOSITORY_NAME }}.xml
- name: ReportGenerator
uses: danielpalme/[email protected]
with:
reports: "${{ env.TEST_RESULTS_DIR }}/**/coverag*.cobertura.xml"
targetdir: ${{ env.COVERAGE_REPORT_DIR }}
reporttypes: 'HtmlInline;Cobertura'
historydir: ${{ env.COVERAGE_HISTORY_DIR }}
- name: Upload coverage report artifact
uses: actions/upload-artifact@v3
with:
name: CoverageReport
path: ${{ env.COVERAGE_REPORT_DIR }}
- name: Pack
run: dotnet pack --no-restore --no-build -p:PackageVersion=${{ steps.gitversion.outputs.NuGetVersionV2 }} -o ./packages
- name: Teardown test dependencies
if: always()
run: |
docker compose down
- name: Publish packages
run: dotnet nuget push ${{ github.workspace }}/packages/**/*.nupkg -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json
- name: Tag published version
uses: actions/github-script@v7
if: (github.ref == 'refs/heads/main')
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{ steps.gitversion.outputs.MajorMinorPatch }}',
sha: context.sha,
force: true
})
- name: Create release
uses: ncipollo/release-action@v1
if: (github.ref == 'refs/heads/main')
with:
name: Release ${{ steps.gitversion.outputs.MajorMinorPatch }}
tag: ${{ steps.gitversion.outputs.MajorMinorPatch }}
token: ${{ secrets.GITHUB_TOKEN }}
generateReleaseNotes: true