-
Notifications
You must be signed in to change notification settings - Fork 1k
154 lines (127 loc) · 4.43 KB
/
build-test.yml
File metadata and controls
154 lines (127 loc) · 4.43 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
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
name: Build and Test
on:
workflow_dispatch:
inputs:
tag:
description: 'Tag Ref'
required: true
pull_request:
branches: [ master ]
push:
branches: [ master ]
release:
jobs:
Build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
target: [netstandard2.0, netstandard2.1, net6.0, net462]
env:
LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.events.inputs.tag }}
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Show .NET info
run: dotnet --info
- name: Build library (Debug)
run: dotnet build -c debug -f ${{ matrix.target }} ${{ env.LIB_PROJ }}
- name: Build library (Release)
run: dotnet build -c release -f ${{ matrix.target }} ${{ env.LIB_PROJ }}
Test:
runs-on: ${{ matrix.os }}-latest
strategy:
fail-fast: false
matrix:
# Windows testing is combined with code coverage
os: [ubuntu, macos]
target: [net6.0]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET Core
if: matrix.target == 'net6.0'
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Restore test dependencies
run: dotnet restore
- name: Run tests (Debug)
run: dotnet test -c debug -f ${{ matrix.target }} --no-restore
- name: Run tests (Release)
run: dotnet test -c release -f ${{ matrix.target }} --no-restore
CodeCov:
name: Code Coverage
runs-on: windows-latest
env:
DOTCOVER_VER: 2024.1.4
DOTCOVER_PKG: JetBrains.dotCover.CommandLineTools
COVER_SNAPSHOT: SharpZipLib.dcvr
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Install codecov
run: dotnet tool install ${{env.DOTCOVER_PKG}} --global --version ${{env.DOTCOVER_VER}}
- name: Run tests with code coverage
run: dotnet-dotCover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c Release
- name: Create code coverage report
run: dotnet-dotCover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: dotcover-report.xml
- name: Upload coverage snapshot artifact
uses: actions/upload-artifact@v4
with:
name: Code coverage snapshot
path: ${{env.COVER_SNAPSHOT}}
Pack:
needs: [Build, Test, CodeCov]
runs-on: windows-latest
env:
PKG_SUFFIX: ''
PKG_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
PKG_PROPS: '/p:ContinuousIntegrationBuild=true /p:EmbedUntrackedSources=true'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.events.inputs.tag }}
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
- name: Build library
run: dotnet build -c Release ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- name: Add PR suffix to package
if: ${{ github.event_name == 'pull_request' }}
run: echo "PKG_SUFFIX=-PR" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Set package version
continue-on-error: true
run: |-
$PKG_GIT_VERSION="$(git describe --tags --abbrev | % { $_.substring(1) })"
Write-Output "::notice::Git describe: $PKG_GIT_VERSION"
Write-Output "::notice::Package suffix: $env:PKG_SUFFIX"
$PKG_VERSION = "${PKG_GIT_VERSION}${env:PKG_SUFFIX}"
Write-Output "::notice::Package version: $PKG_VERSION"
Write-Output "PKG_VERSION=$PKG_VERSION" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Create nuget package
run: dotnet pack ${{ env.PKG_PROJ }} -c Release --output dist ${{ env.PKG_PROPS }} /p:Version=${{ env.PKG_VERSION }}
- name: Upload nuget package artifact
uses: actions/upload-artifact@v4
with:
name: Nuget package
path: dist/*.nupkg