-
Notifications
You must be signed in to change notification settings - Fork 35
177 lines (161 loc) · 5.65 KB
/
dotnet.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
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: dotnet
permissions: read-all
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
version:
description: 'Release version to tag and create'
required: false
env:
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
NuGetDirectory: ${{ github.workspace }}/nuget
jobs:
build:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c ${{ matrix.configuration }} --no-restore
- name: Test
run: dotnet test -c ${{ matrix.configuration }} --no-build --verbosity normal --collect:"XPlat Code Coverage"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
flags: ${{ matrix.os }},${{ matrix.configuration }}
format:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Format verify no changes
run: dotnet format --verify-no-changes
test-parsers:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build -c ${{ matrix.configuration }} --no-restore
- name: Test Parsers
shell: pwsh
run: ./test-parsers.ps1
pack:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Get all history to allow automatic versioning using MinVer
- name: Create tag (to set version of nuget package)
if: ${{ github.event.inputs.version != '' && github.actor == 'nietras' }}
run: |
git tag v${{ github.event.inputs.version }}
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
# No need to define min ver version globally now since only uploading release
# when version and tag is defined.
# - name: Install MinVer
# run: dotnet tool install --global minver-cli --version 4.3.0
# - name: Run MinVer
# run: minver -v d -t v -p preview
# - name: Run MinVer (output)
# id: minverrun
# run: |
# echo "MINVERVERSIONOVERRIDE=$(minver -v d -t v -p preview)" >> $env:GITHUB_ENV
# - name: Output MinVer
# run: |
# echo "${{ env.MINVERVERSIONOVERRIDE }}"
- name: Pack nuget package
run: dotnet pack -c Release --output ${{ env.NuGetDirectory }}
- name: Get version of dll
run: (Get-Item ./artifacts/bin/Sep/release_net8.0/Sep.dll).VersionInfo.ProductVersion
- uses: actions/upload-artifact@v3
with:
name: nuget
if-no-files-found: error
retention-days: 7
path: ${{ env.NuGetDirectory }}/*nupkg
create-release-push:
needs: [ build, pack ]
runs-on: windows-latest
permissions:
contents: write
if: ${{ github.event.inputs.version != '' && github.actor == 'nietras' }}
steps:
- uses: actions/checkout@v3
- name: Download nuget packages
uses: actions/download-artifact@v3
with:
name: nuget
path: ${{ env.NuGetDirectory }}
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ github.event.inputs.version }}
release_name: ${{ github.event.inputs.version }}
draft: true
- name: Create tag (for release)
run: |
git tag v${{ github.event.inputs.version }}
git push origin v${{ github.event.inputs.version }}
- name: Upload nupkg package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.NuGetDirectory }}/Sep.${{ github.event.inputs.version }}.nupkg
asset_name: Sep.${{ github.event.inputs.version }}.nupkg
asset_content_type: application/zip
- name: Upload snupkg package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.NuGetDirectory }}/Sep.${{ github.event.inputs.version }}.snupkg
asset_name: Sep.${{ github.event.inputs.version }}.snupkg
asset_content_type: application/zip
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Push nupkg package
run: dotnet nuget push ${{ env.NuGetDirectory }}/Sep.${{ github.event.inputs.version }}.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Push snupkg package
run: dotnet nuget push ${{ env.NuGetDirectory }}/Sep.${{ github.event.inputs.version }}.snupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate