forked from icsharpcode/SharpZipLib
-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (136 loc) · 5.1 KB
/
build-test.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
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]
env:
LIB_PROJ: src/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib.csproj
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.events.inputs.tag }}
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
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@v2
with:
fetch-depth: 0
- name: Setup .NET Core
if: matrix.target == 'net6.0'
uses: actions/setup-dotnet@v1
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-2019
env:
DOTCOVER_VER: 2021.1.2
DOTCOVER_PKG: jetbrains.dotcover.commandlinetools
COVER_SNAPSHOT: SharpZipLib.dcvr
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
# NOTE: This is the temporary fix for https://github.com/actions/virtual-environments/issues/1090
- name: Cleanup before restore
run: dotnet clean ICSharpCode.SharpZipLib.sln && dotnet nuget locals all --clear
- name: Install codecov
run: nuget install -o tools -version ${{env.DOTCOVER_VER}} ${{env.DOTCOVER_PKG}}
- name: Add dotcover to path
run: echo "$(pwd)\tools\${{env.DOTCOVER_PKG}}.${{env.DOTCOVER_VER}}\tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Run tests with code coverage
run: dotcover dotnet --output=${{env.COVER_SNAPSHOT}} --filters=-:ICSharpCode.SharpZipLib.Tests -- test -c release
- name: Create code coverage report
run: dotcover report --source=${{env.COVER_SNAPSHOT}} --reporttype=detailedxml --output=dotcover-report.xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1.2.2
with:
files: dotcover-report.xml
- name: Upload coverage snapshot artifact
uses: actions/upload-artifact@v2
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@v2
with:
ref: ${{ github.events.inputs.tag }}
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0.x'
- name: Build library for .NET Standard 2.0
run: dotnet build -c Release -f netstandard2.0 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- name: Build library for .NET Standard 2.1
run: dotnet build -c Release -f netstandard2.1 ${{ env.PKG_PROPS }} ${{ env.PKG_PROJ }}
- name: Build library for .NET 6.0
run: dotnet build -c Release -f net6.0 ${{ 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@v2
with:
name: Nuget package
path: dist/*.nupkg